about movie help!

edited December 2015 in Library Questions

Hi guys. I have a trouble on my code. I want to make a 80x45 pixels mov into 640x360 pixels display. But, it has a error on row 22. Help me~~~~

import processing.video.*;
int cell;
int col, row;
Movie m;

void setup() {
  size(640, 360); // 8 times mov
  m = new Movie(this, "m_80_45.mov"); //mov size is 80x45 pixels
  cell = 8;
  col = width/cell;
  row = height/cell;
}

void draw() {
  if (m.available()) {
    m.read();
  }
  m.loadPixels();
  for (int i=0; i<col; i++) {
    for (int j=0; j<row; j++) {
      int loc = i + j*m.width;
      color c = m.pixels[loc]; // this row has error! say: ArrayIndexOutOfBoundsException:0
      fill(c);
      int x = i*cell;
      int y = j*cell;
      rect(x, y, cell, cell);
    }
  }
}

Answers

  • Answer ✓

    you should have the for loop within the if-clause that says if (m.available()) {

Sign In or Register to comment.