Package com.jetbrains

Interface Screenshoter


@Service @Provided public interface Screenshoter
Provides a way to take screenshots of an individual Window without involving the operating system's window manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    getWindowBackbufferArea(Window window, int x, int y, int width, int height)
    Returns a snapshot of the window's client area from its backbuffer, if any.
    getWindowSurfaceArea(Window window, int x, int y, int width, int height)
    Captures the specified area of the client region of a given window from its underlying pixel representation, and returns it as an image.
  • Method Details

    • getWindowBackbufferArea

      BufferedImage getWindowBackbufferArea(Window window, int x, int y, int width, int height)

      Returns a snapshot of the window's client area from its backbuffer, if any. If window has no associated backbuffer, null is returned.

      Note: the use of the backbuffer is primarily controlled by the swing.bufferPerWindow system property (true by default).

      The coordinates and size are given in the window's client area coordinate system, which is the area of a window not covered by the window's decorations such as the system title bar. The pixel with the coordinates (x, y) of the window's client area will be at (0, 0) in the returned image.

      width and height are clipped to the window's client area, so Integer.MAX_VALUE can be used safely.

      IllegalArgumentException is thrown if either of the following holds:

      • width or height is negative or zero.
      • x or y are outside the window's client area.
      Parameters:
      window - window to take a screenshot of; must not be null
      x - x coordinate within the window's client area
      y - y coordinate within the window's client area
      width - width of the screenshot; clipped to the window's client area
      height - height of the screenshot; clipped to the window's client area
      Returns:
      a snapshot of the window's client area from the window's backbuffer, if any. null if the window has no backbuffer or if the window is not visible. The returned image is a copy of the image in the buffer strategy, so the caller can modify it.
    • getWindowSurfaceArea

      BufferedImage getWindowSurfaceArea(Window window, int x, int y, int width, int height)

      Captures the specified area of the client region of a given window from its underlying pixel representation, and returns it as an image.

      The coordinates and size are given in the window's client area coordinate system, which is the area of a window not covered by the window's decorations such as the system title bar. The pixel with the coordinates (x, y) of the window's client area will be at (0, 0) in the returned image.

      IllegalArgumentException is thrown if either of the following holds:

      • width or height is negative or zero.
      • x or y are outside the window's client area.
      Note: Currently available only on Linux with WLToolkit.
      Parameters:
      window - window to take a screenshot of; must not be null
      x - x coordinate within the window's client area
      y - y coordinate within the window's client area
      width - width of the area to screenshot; clipped to the window's client area
      height - height of the area to screenshot; clipped to the window's client area
      Returns:
      a snapshot of the window's client area from its underlying graphics subsystem representation. null if the window is not visible. Since the actual pixels of the window may be scaled depending on Java or operating system settings, the size of the returned image may differ from width and height. The returned image is a copy, so the caller can modify it.