-
Enhancement
-
Resolution: Duplicate
-
P5
-
None
-
5.0
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
If anyone calls captureScreenshot in any loop, the metod initializes every time a int[width*height] array. For a nomal screen capture of 1280*1024 it costs 40-60ms of time every time the method called (depends on the pc). This can be a huge amount of time when doing in a loop. Furthermore, if someone needs only the data (the int[] array what the native interface made anyway), there wouldnt be needed a BufferedImage creation at all.
JUSTIFICATION :
Performance.. is there any better reason?
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the possibility to give an already created int[] array to the method which will do the capture into that given array, and thats it.
ACTUAL -
Robot.createScreencapture returns with a BufferedImage, but the image and its data array is recreated every time the method is called, thus takes a huge amount of time.
CUSTOMER SUBMITTED WORKAROUND :
java.awt.peer.RobotPeer:
public void getRGBPixels(Rectangle rectangle, int[] is);
sun.awt.windows.WRobotPeer:
public void getRGBPixels(Rectangle rectangle, int[] is) {
rectangle.translate(offset.x, offset.y);
getRGBPixels(rectangle.x, rectangle.y, rectangle.width,
rectangle.height, is);
}
java.awt.Robot:
public synchronized void createScreenCaptureIntArray(Rectangle screenRect, int[] is) {
peer.getRGBPixels(screenRect, is);
}
If anyone calls captureScreenshot in any loop, the metod initializes every time a int[width*height] array. For a nomal screen capture of 1280*1024 it costs 40-60ms of time every time the method called (depends on the pc). This can be a huge amount of time when doing in a loop. Furthermore, if someone needs only the data (the int[] array what the native interface made anyway), there wouldnt be needed a BufferedImage creation at all.
JUSTIFICATION :
Performance.. is there any better reason?
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the possibility to give an already created int[] array to the method which will do the capture into that given array, and thats it.
ACTUAL -
Robot.createScreencapture returns with a BufferedImage, but the image and its data array is recreated every time the method is called, thus takes a huge amount of time.
CUSTOMER SUBMITTED WORKAROUND :
java.awt.peer.RobotPeer:
public void getRGBPixels(Rectangle rectangle, int[] is);
sun.awt.windows.WRobotPeer:
public void getRGBPixels(Rectangle rectangle, int[] is) {
rectangle.translate(offset.x, offset.y);
getRGBPixels(rectangle.x, rectangle.y, rectangle.width,
rectangle.height, is);
}
java.awt.Robot:
public synchronized void createScreenCaptureIntArray(Rectangle screenRect, int[] is) {
peer.getRGBPixels(screenRect, is);
}
- duplicates
-
JDK-4776469 RFE: Need createScreenCapture(BufferedImage img, int offsetX, int offsetY)
- Open