reading pixel values

edited February 2016 in Questions about Code

Why does this give me garbage numbers for values of pixels?

PImage img;
void setup() 
{
  size(1000, 600);
  img = loadImage("c:/acquire/test1.png");
  img.loadPixels();
  print(img.height,img.width,"\n");
  print(img.pixels[42100]);
  print(img.get(100,100));
  img.updatePixels();
}

void draw()
{
  img.resize(400, 525);
  image(img, 0, 0);
}  

print at bottom is:

4200 3200 -394579 -460552 (should be gray value 0-255)

Tagged:
Sign In or Register to comment.