In this java example program we have to write code for getting the pixel color of an image. To get the pixel color we need to first have an image and then we will be able to get the pixel color of any specific or particular pixel in the RGB format.
File file= new File("rockface.jpg");
BufferedImage image = ImageIO.read(file);
Above line of code creates an object of File with the image named "rockface.jpg" now we will read this file with the static method of ImageIO read(). Now we can get the pixel color with the getRGB() method with the image object.
Here is the example code of GetPixelColor.java as follows:
Output of the above Code:
Red Color value = 33
Green Color value = 50
Blue Color value = 60
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: October 23, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles