getRGB

Discussion in 'Java' started by patrick, May 20, 2004.

  1. patrick

    patrick Guest

    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;
    }
    patrick, May 20, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. patrick

    getRGB

    patrick, Jul 1, 2004, in forum: Java
    Replies:
    2
    Views:
    2,382
    patrick
    Jul 1, 2004
  2. royG
    Replies:
    3
    Views:
    547
    Mayeul
    Nov 17, 2008
  3. preventsmash

    Help with .getRGB() method

    preventsmash, Dec 15, 2009, in forum: Java
    Replies:
    0
    Views:
    664
    preventsmash
    Dec 15, 2009
Loading...

Share This Page