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 & HelpSyntax Questions › img.length cannot be resolved or is not a field
Page Index Toggle Pages: 1
img.length cannot be resolved or is not a field (Read 1372 times)
img.length cannot be resolved or is not a field
Jan 18th, 2010, 5:18am
 
I got this function in a class, before i used:

//    for(int y = 0; y < img.height; y++){
//      for(int x = 0; x < img.width; x++){

which worked fine, now i changed to img.length but now i get the error img.length cannot be resolved or is not a field.
why's that?

Code:
    void calculate2d(PImage img, boolean[] ar){
img.loadPixels();
println(img.length);
for(int i = 0; i < img.length; i++){
if(img.pixels[i] != -1){//als het niet wit is
ar[i] = true;
}
}
}
Re: img.length cannot be resolved or is not a field
Reply #1 - Jan 18th, 2010, 5:23am
 
An image does not have a length.

You could try:

for(int i = 0; i < img.pixels.length; i++){
Re: img.length cannot be resolved or is not a field
Reply #2 - Jan 18th, 2010, 10:44am
 
how could i forget.

thx
Page Index Toggle Pages: 1