com.badlogic.gdx.utils
Class ScreenUtils

java.lang.Object
  extended by com.badlogic.gdx.utils.ScreenUtils

public 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.

Author:
espitz

Constructor Summary
ScreenUtils()
           
 
Method Summary
static 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 TextureRegion getFrameBufferTexture()
          Returns the default framebuffer contents as a TextureRegion 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 a TextureRegion with the same dimensions.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenUtils

public ScreenUtils()
Method Detail

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 MathUtils.nextPowerOfTwo(int) dimensions and RGBA8888 Pixmap.Format. It can be accessed via TextureRegion.getTexture(). 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 MathUtils.nextPowerOfTwo(int) dimensions and RGBA8888 Pixmap.Format. It can be accessed via TextureRegion.getTexture(). 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)

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 cheap operation, so use this functionality wisely.

Parameters:
flipY - whether to flip pixels along Y axis


Copyright © 2013. All Rights Reserved.