getRGB

P

patrick

Hello,

i use getRGB(i,j) to accumulate a number myRGB to decide if a particular
image is on the screen:

for each pixel:
{ x=(long)image1.getRGB(i,j);
myRGB=myRGB + x;
} //

So I get a fixed total ,myRGB, for a particular image at 1024 by 768.This
works fine to identify the image.
My problem is I get a different number for the same image at 800 by 600.
Ive no idea how they are related.
Maybe somebody could help.

Thanks
patrick
The full method is as follows:

//return a number identifying the image within the rect =area in image1.:
public long getrgb (BufferedImage image1,Rectangle area)
{ long myRGB=0L,x=0L;
for(int i=area.x;i<(area.x+area.width);i++)
{
for(int j=area.y;j<(area.y+area.height);j++)
{ x=(long)image1.getRGB(i,j);
myRGB=myRGB + x;
} //
} // end for width
myRGB= myRGB/1000000L;
return myRGB;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top