Class DesktopInteractImpl

  • All Implemented Interfaces:
    DesktopInteract

    public class DesktopInteractImpl
    extends Object
    implements DesktopInteract
    Capture desktop screen either via native code (JNI) if available or by using java.awt.Robot.
    Author:
    Sebastien Vincent
    See Also:
    Robot
    • Method Detail

      • captureScreen

        public boolean captureScreen​(int display,
                                     byte[] output)
        Capture the full desktop screen using native grabber. Contrary to other captureScreen method, it only returns raw bytes and not BufferedImage. It is done in order to limit slow operation such as converting ARGB images (uint32_t) to bytes especially for big big screen. For example a 1920x1200 desktop consumes 9 MB of memory for grabbing and another 9 MB array for conversion operation.
        Specified by:
        captureScreen in interface DesktopInteract
        Parameters:
        display - index of display
        output - output buffer to store bytes in. Be sure that output length is sufficient
        Returns:
        true if success, false if JNI error or output length too short
      • captureScreen

        public boolean captureScreen​(int display,
                                     long buffer,
                                     int bufferLength)
        Capture the full desktop screen using native grabber. Contrary to other captureScreen method, it only returns raw bytes and not BufferedImage. It is done in order to limit slow operation such as converting ARGB images (uint32_t) to bytes especially for big big screen. For example a 1920x1200 desktop consumes 9 MB of memory for grabbing and another 9 MB array for conversion operation.
        Specified by:
        captureScreen in interface DesktopInteract
        Parameters:
        display - index of display
        buffer - native output buffer to store bytes in. Be sure that output length is sufficient
        bufferLength - length of native buffer
        Returns:
        true if success, false if JNI error or output length too short
      • captureScreen

        public boolean captureScreen​(int display,
                                     int x,
                                     int y,
                                     int width,
                                     int height,
                                     byte[] output)
        Capture a part of the desktop screen using native grabber. Contrary to other captureScreen method, it only returns raw bytes and not BufferedImage. It is done in order to limit slow operation such as converting ARGB images (uint32_t) to bytes especially for big big screen. For example a 1920x1200 desktop consumes 9 MB of memory for grabbing and another 9 MB array for conversion operation.
        Specified by:
        captureScreen in interface DesktopInteract
        Parameters:
        display - index of display
        x - x position to start capture
        y - y position to start capture
        width - capture width
        height - capture height
        output - output buffer to store bytes in. Be sure that output length is sufficient
        Returns:
        true if success, false if JNI error or output length too short
      • captureScreen

        public boolean captureScreen​(int display,
                                     int x,
                                     int y,
                                     int width,
                                     int height,
                                     long buffer,
                                     int bufferLength)
        Capture a part of the desktop screen using native grabber. Contrary to other captureScreen method, it only returns raw bytes and not BufferedImage. It is done in order to limit slow operation such as converting ARGB images (uint32_t) to bytes especially for big big screen. For example a 1920x1200 desktop consumes 9 MB of memory for grabbing and another 9 MB array for conversion operation.
        Specified by:
        captureScreen in interface DesktopInteract
        Parameters:
        display - index of display
        x - x position to start capture
        y - y position to start capture
        width - capture width
        height - capture height
        buffer - native output buffer to store bytes in. Be sure that output length is sufficient
        bufferLength - length of native buffer
        Returns:
        true if success, false if JNI error or output length too short
      • captureScreen

        public BufferedImage captureScreen()
        Capture the full desktop screen using java.awt.Robot.
        Specified by:
        captureScreen in interface DesktopInteract
        Returns:
        BufferedImage of the desktop screen
      • captureScreen

        public BufferedImage captureScreen​(int x,
                                           int y,
                                           int width,
                                           int height)
        Capture a part of the desktop screen using java.awt.Robot.
        Specified by:
        captureScreen in interface DesktopInteract
        Parameters:
        x - x position to start capture
        y - y position to start capture
        width - capture width
        height - capture height
        Returns:
        BufferedImage of a part of the desktop screen or null if Robot problem