The color class is used to manipulate colours using the methods and constants defined in it. Every colour is a combination of red, green and blue. Combinations of these three colours, which take values from 0 to 255 or 0.0 to 1.0, can generate any new colour. Therefore, the Color class has two constructors, one takes integer parameters and another takes float parameters.
public Color( int r, int g. int b ) ;
public Color( float r, float g. float b ) ;
The Graphics class has the methods set and get which can be used to set the colour of the object that is being drawn and to get the colour of the drawing object, respectively.
public class ImageColorExample
public static void main(String args) throws IOException
File Picture = new File("Photo.jpg");
BufferedImage JPGPic = ImageIO.read(Picture);
int clr = JPGPic.getRGB(100,40);
int Red =(clr & 0x00ff0000)>> 16;
int Green =(clr & 0x0000ff00)>>8;
int Blue =clr & 0x000000ff;
System.out.println("Red Color value ="+Red);
System.out.println("Green Color value ="+Green);
System.out.println("Blue Color value ="+Blue);