Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can not get individual pixel values

 
Mahesh Chavan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know individual alpha red blue and green values of a pixel. Following code displays image from a file ( given as first argument ) but does not show any rgba vaures ( all values returned are 0 )
Pl. let me know what is the error in the code :

I have also tried to get rgba values in a array int rgba[] form. But I am always getting zero values for all pixels.
Please help.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mahesh, and welcome to the Ranch! Please BeForthrightWhenCrossPostingToOtherSites
https://forums.oracle.com/forums/thread.jspa?threadID=2403002

edit:
http://www.java-forums.org/awt-swing/60745-how-get-individual-pixel-colors.html
http://www.javaprogrammingforums.com/awt-java-swing/16193-can-not-get-individual-pixel-values-using-getrgb.html#post68931

Also, the code you copied and added to has been around for more than 12 years*. I suggest you go through the Swing trail of the Oracle tutorials, where you will find updated sample code that (a) respects Swing's single threaded rule and (b) doesn't use methods that have been deprecated since that coed was written.

* http://www.jguru.com/faq/view.jsp?EID=53328
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic