Package arc.util

Class ScreenUtils

java.lang.Object
arc.util.ScreenUtils

public final class ScreenUtils extends Object
Class with static helper methods that provide access to the default OpenGL FrameBuffer. These methods can be used to get the entire screen content or a portion thereof.
  • Constructor Details

    • ScreenUtils

      public ScreenUtils()
  • Method Details

    • saveScreenshot

      public static void saveScreenshot(Fi file)
    • saveScreenshot

      public static void saveScreenshot(Fi file, int x, int y, int width, int height)
    • getFrameBufferTexture

      public static TextureRegion getFrameBufferTexture()
      Returns the default framebuffer contents as a TextureRegion with a width and height equal to the current screen size. The base Texture always has Mathf.nextPowerOfTwo(int) dimensions and RGBA8888 Pixmap.Format. The texture is not managed and has to be reloaded manually on a context loss. The returned TextureRegion is flipped along the Y axis by default.
    • getFrameBufferTexture

      public static TextureRegion getFrameBufferTexture(int x, int y, int w, int h)
      Returns a portion of the default framebuffer contents specified by x, y, width and height as a TextureRegion with the same dimensions. The base Texture always has Mathf.nextPowerOfTwo(int) dimensions and RGBA8888 Pixmap.Format. This texture is not managed and has to be reloaded manually on a context loss. If the width and height specified are larger than the framebuffer dimensions, the Texture will be padded accordingly. Pixels that fall outside of the current screen will have RGBA values of 0.
      Parameters:
      x - the x position of the framebuffer contents to capture
      y - the y position of the framebuffer contents to capture
      w - the width of the framebuffer contents to capture
      h - the height of the framebuffer contents to capture
    • getFrameBufferPixmap

      public static Pixmap getFrameBufferPixmap(int x, int y, int w, int h)
    • getFrameBufferPixmap

      public static Pixmap getFrameBufferPixmap(int x, int y, int w, int h, boolean flip)
    • getFrameBufferPixels

      public static byte[] getFrameBufferPixels(boolean flipY)
      Returns the default framebuffer contents as a byte[] array with a length equal to screen width * height * 4. The byte[] will always contain RGBA8888 data. Because of differences in screen and image origins the framebuffer contents should be flipped along the Y axis if you intend save them to disk as a bitmap. Flipping is not a cheap operation, so use this functionality wisely.
      Parameters:
      flipY - whether to flip pixels along Y axis
    • getFrameBufferPixels

      public static byte[] getFrameBufferPixels(int x, int y, int w, int h, boolean flipY)
      Returns a portion of the default framebuffer contents specified by x, y, width and height, as a byte[] array with a length equal to the specified width * height * 4. The byte[] will always contain RGBA8888 data. If the width and height specified are larger than the framebuffer dimensions, the Texture will be padded accordingly. Pixels that fall outside of the current screen will have RGBA values of 0. Because of differences in screen and image origins the framebuffer contents should be flipped along the Y axis if you intend save them to disk as a bitmap. Flipping is not a cheap operation, so use this functionality wisely.
      Parameters:
      flipY - whether to flip pixels along Y axis