Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Pixel Question  RSS feed

 
James Gray
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to get the color of a JPanel's pixel (the way it's currently painting itself) at given coordinates?
------------------
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,
Presumably you have an image on your panel... if not all the pixels are the same color.
So you could use a java.awt.image.pixelGrabber and call getColorModel() on it -
and then the getRed(), getGreen() getBlue() getAlpha() on each of the pixels in the array....
I haven't actually tried any code so there might be a better way to do this.
Bye,
Terry
 
James Gray
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, it was drawn on with Graphics calls. That's primarily what I'm looking for, how to get that Image.
------------------
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!