2 years ago

#95621

test-img

Some Guy

What color encoding scheme is used for Java Robot's screen capture?

I am trying to get screen captures of my computer screen and then process the data. Since I am processing the data, I need to know what color scheme like ARGB or RGB or BGR is being used for the following BufferedImage used to store the screen capture.

BufferedImage img = robot.createScreenCapture(new Rectangle(0,0,Toolkit.getDefaultToolkit().getScreenSize().width,Toolkit.getDefaultToolkit().getScreenSize().height));

I wrote these lines of code to see if the color scheme used made a difference in the data received

int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
Color color = new Color(pixels[80000], true);
System.out.println( "ALPHA: " + color.getAlpha());
System.out.println( "RED: " + color.getRed());
System.out.println( "GREEN: " + color.getGreen());
System.out.println( "BLUE: " + color.getBlue());
        
color = new Color(pixels[80000], false);
System.out.println( "ALPHA: " + color.getAlpha());
System.out.println( "RED: " + color.getRed());
System.out.println( "GREEN: " + color.getGreen());
System.out.println( "BLUE: " + color.getBlue());

The first color is created with an alpha value, but the second one drops it. And, this was the result

ALPHA: 255

RED: 63

GREEN: 72

BLUE: 204

ALPHA: 255

RED: 63

GREEN: 72

BLUE: 204

So, it appears that the two sets are identical despite using two different color schemes. Why is this? Do the screen captures not have a specific color scheme?

java

image-processing

colors

rgb

argb

0 Answers

Your Answer

Accepted video resources