by Dinesh Thakur Category: AWT and Applets

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.

BufferedImage class is an extension of java.awt.Image found in java.awt.image package, allowing Direct access to all methods of a Image object.

import java.awt.*;
import javax.imageio.*;
import java.awt.image.BufferedImage;
public class ImageColorExample
           public static void main(String args[]) throws IOException
          File Picture = new File("Photo.jpg");
          BufferedImage JPGPic =;
          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);

Get Pixel Color BufferedImage

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles