Package arc.util
Class ScreenUtils
java.lang.Object
arc.util.ScreenUtils
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
getFrameBufferPixels
(boolean flipY) Returns the default framebuffer contents as a byte[] array with a length equal to screen width * height * 4.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.static Pixmap
getFrameBufferPixmap
(int x, int y, int w, int h) static Pixmap
getFrameBufferPixmap
(int x, int y, int w, int h, boolean flip) static TextureRegion
Returns the default framebuffer contents as aTextureRegion
with a width and height equal to the current screen size.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 aTextureRegion
with the same dimensions.static void
saveScreenshot
(Fi file) static void
saveScreenshot
(Fi file, int x, int y, int width, int height)
-
Constructor Details
-
ScreenUtils
public ScreenUtils()
-
-
Method Details
-
saveScreenshot
-
saveScreenshot
-
getFrameBufferTexture
Returns the default framebuffer contents as aTextureRegion
with a width and height equal to the current screen size. The baseTexture
always hasMathf.nextPowerOfTwo(int)
dimensions and RGBA8888Pixmap.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
Returns a portion of the default framebuffer contents specified by x, y, width and height as aTextureRegion
with the same dimensions. The baseTexture
always hasMathf.nextPowerOfTwo(int)
dimensions and RGBA8888Pixmap.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 capturey
- the y position of the framebuffer contents to capturew
- the width of the framebuffer contents to captureh
- the height of the framebuffer contents to capture
-
getFrameBufferPixmap
-
getFrameBufferPixmap
-
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
-