We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › am i stupid or what
Page Index Toggle Pages: 1
am i stupid or what? (Read 304 times)
am i stupid or what?
Sep 7th, 2008, 7:47pm
 
i try to get a image masked. i tried it several times. always get stuck with the same thing. i guess its very easy...

size(200,200);
background(0,200,0);
PImage img= loadImage("http://processing.org/img/cover/cover_greenberg.jpg");
//image(img,10,10);
int sz= img.pixels.length;
int[] maskArray= new int[sz];
for(int i=0; i< sz; i++) {
 if(img.pixels[sz]==#000000)
   maskArray[i]=255;
 else
   maskArray[i]=0;
}
img.mask(maskArray);
image(img,10,10);

WTF? why an out of bounds?
Re: am i stupid or what?
Reply #1 - Sep 8th, 2008, 8:34am
 
this will fail since all arrays are zero-based, indices [0,1,.....,array.length-1]:

img.pixels[sz]; // i guess you ment "i", or "sz-1" ...

F
Page Index Toggle Pages: 1