This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Im trying to figure out how you can determine the colour of a pixel in the buffer of a JPanel.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
You can't do that easily. Usually, to get a pixel valuem, one is buffering in a java.awt.image.BufferedImage and uses its getRGB method. You can scrape pixels off the screen, but that be nasty.
There is no emoticon for what I am feeling!
Jonathan Steel
Greenhorn
Joined: Jan 26, 2005
Posts: 13
posted
0
Thanks for the reply.
I guess ill have to go the back buffer route then. I had hoped i could circumvent that option because Im trying to make a 4K game and this approach is sure to eat up some precious bytes.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Another approach could be to "calculate" the pixel from the application state of your program. For example, if I were writing a chess game, given a (x,y) location I would check if the location was on the board or not; if on the chess board, if there was a piece on that square; if there was a piece, take the piece's image...
Jonathan Steel
Greenhorn
Joined: Jan 26, 2005
Posts: 13
posted
0
Gotcha. I cant take that route though because Im actually using the buffer to store the information about my game world. Strange, I know. Im doing this because there will be debris all over the screen not very easily represented by any data structures due to the operations ill be performing on them. I want to know the colour of a pixel to use for collision detection.