Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > getRGB

Reply
Thread Tools

getRGB

 
 
patrick
Guest
Posts: n/a
 
      05-20-2004
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;
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with .getRGB() method preventsmash Java 0 12-15-2009 09:11 PM
recreating an image using int[] from getRGB() royG Java 3 11-17-2008 04:20 PM
getRGB patrick Java 2 07-01-2004 02:54 PM



Advertisments