i fairly new to java and i am currently working an ambiant light for my screen. I wanted to write a programm that captures my screen and then calculates the averages of the colors at the edge of my screen.
public class MeasureRun {
public static void main(String[] args) {
long start=System.currentTimeMillis();
Rectangle screenRect1 = new Rectangle(1536,864);
for (int i = 0; i <10; i++) {
try {
Robot robot = new Robot();
BufferedImage screenLeft = robot.createScreenCapture(screenRect1);;
} catch (AWTException ex) {
System.err.println(ex);
}
}
long end=System.currentTimeMillis();
long elap=end-start;
System.out.println(elap);
}
}
This is the code i use the Capture the screen and measure how long it takes. The problem is it takes about 6 Seconds for 10 Screenshots to be made even without the calculations of the edge colors. However since i would like the colors of my ambient light to change almost simultaniously with the screen, this is obviously way to slow.
Is there any way to improve this program so that i cap more pictures per second?