Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 .getRGB () - how does it work?????
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
blackhawk_prince




PostPosted: Sat Apr 19, 2008 2:05 pm   Post subject: .getRGB () - how does it work?????

I am risk (the board game) and I am trying to figure out how to know if a territory was clicked. I have to images loaded the world map and a colour coded map. I made it so each territory has a unique RGB colour. I am basically try to code if colourCodedMap's rgb at x, y == territory [i]'s rgb at x, y then territory [i] is clicked. In turing i could have used whatdotColour to find the colour and java as a .getRGB () method. I am not sure how to used and i could not find any good examples. If anyone could help me i would appreciate it.
Java API:
int getRGB(int x, int y)
Returns an integer pixel in the default RGB color model (TYPE_INT_ARGB) and default sRGB colorspace.

int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
Returns an array of integer pixels in the default RGB color model (TYPE_INT_ARGB) and default sRGB color space, from a portion of the image data.
Sponsor
Sponsor
Sponsor
sponsor
jernst




PostPosted: Sat Apr 19, 2008 4:26 pm   Post subject: Re: .getRGB () - how does it work?????

I read through the BufferedImage class documentation and it seems like "int getRGB(int x, int y)" returns the RGB color code of the pixel at the given x,y position. So you should be able to send it the co-ordinates where the person clicked the mouse and then check if the RGB value is the same as the RGB value you have set to the region. The second function you showed seems to work similarly over a rectangular area so that might not be as useful. You seem to be on the right track with what you've been using so far.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: