Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6415716

WRobotPeer + Robot .captureScreenshot recreates a huge int array every time

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 5.0
    • client-libs
    • 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);
          }

            art Artem Ananiev (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: