Hi,
How can I make a color picker, which gets a value of images pixel and refreshes any time I click on different pixel, shows it? It must be done in java.
Hi,
How can I make a color picker, which gets a value of images pixel and refreshes any time I click on different pixel, shows it? It must be done in java.
Load the image in a frame.
Use the mouse coordinates from the upper left corner of the image.
Assuming your image is loaded into BufferedImage
, you can use:
int x,y; //populated from Mouse coordinates
int rgb = myBufferedImage.getPixel(x,y);
//to extract colors
int red = (rgb & 0x00ff0000) >> 16;
int green = (rgb & 0x0000ff00) >> 8;
int blue = rgb & 0x000000ff;
// and to create a new Java color
Color c = new Color(red,blue,green);