Class TextureUtils
java.lang.Object
com.blackrook.gloop.opengl.util.TextureUtils
Texture utility class.
All of these methods can be called outside of the graphics thread.
- Author:
- Matthew Tropiano
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intclosestPowerOfTwo(int x) Finds the closest power of two to an integer value, larger than the initial value.static ByteBuffergetARGBByteData(BufferedImage image) Gets the byte data for a texture in ARGB color information per pixel.static ByteBuffergetARGBByteData(BufferedImage... image) Gets the byte data for a contiguous series of textures in ARGB color information per pixel.static ByteBuffergetBGRAByteData(BufferedImage image) Gets the byte data for a texture in BGRA color information per pixel.static ByteBuffergetBGRAByteData(BufferedImage... image) Gets the byte data for a contiguous series of textures in BGRA color information per pixel.static intgetRawSize(BufferedImage image) Returns the raw size in bytes that this image will need for byte buffer/array storage.static ByteBuffergetRGBAByteData(BufferedImage image) Gets the byte data for a texture in ARGB color information per pixel.static ByteBuffergetRGBAByteData(BufferedImage... image) Gets the byte data for a texture in ARGB color information per pixel.static booleanChecks if a texture has power-of-two dimensions.static booleanisPowerOfTwo(int x) Checks if an integer is a valid power of two.static BufferedImagesetImageData(ByteBuffer imageBGRAData, int width, int height) Converts color byte data to a BufferedImage.
-
Constructor Details
-
TextureUtils
public TextureUtils()
-
-
Method Details
-
closestPowerOfTwo
public static int closestPowerOfTwo(int x) Finds the closest power of two to an integer value, larger than the initial value.Examples:
- If x is 19, this returns 32.
- If x is 4, this returns 4.
- If x is 99, this returns 128.
- If x is 129, this returns 256.
- Parameters:
x- the input value.- Returns:
- the closest power of two.
-
isPowerOfTwo
public static boolean isPowerOfTwo(int x) Checks if an integer is a valid power of two.- Parameters:
x- the input value.- Returns:
- true if it is, false if not.
-
hasPowerOfTwoDimensions
Checks if a texture has power-of-two dimensions.- Parameters:
image- the image to check.- Returns:
- true if so, false if not.
-
getRawSize
Returns the raw size in bytes that this image will need for byte buffer/array storage.- Parameters:
image- the image to inspect.- Returns:
- the size in pixels for the image.
-
getBGRAByteData
Gets the byte data for a texture in BGRA color information per pixel.- Parameters:
image- the input image.- Returns:
- a new direct
ByteBufferof the image's byte data.
-
getBGRAByteData
Gets the byte data for a contiguous series of textures in BGRA color information per pixel. Works best if all of the textures are the same size.- Parameters:
image- the image list.- Returns:
- a new direct
ByteBufferof the image's byte data.
-
getARGBByteData
Gets the byte data for a texture in ARGB color information per pixel.- Parameters:
image- the input image.- Returns:
- a new direct
ByteBufferof the image's byte data.
-
getARGBByteData
Gets the byte data for a contiguous series of textures in ARGB color information per pixel. Works best if all of the textures are the same size.- Parameters:
image- the image list.- Returns:
- a new direct
ByteBufferof the image's byte data.
-
getRGBAByteData
Gets the byte data for a texture in ARGB color information per pixel.- Parameters:
image- the input image.- Returns:
- a new direct
ByteBufferof the image's byte data.
-
getRGBAByteData
Gets the byte data for a texture in ARGB color information per pixel.- Parameters:
image- the input image.- Returns:
- a new direct
ByteBufferof the image's byte data.
-
setImageData
Converts color byte data to a BufferedImage.- Parameters:
imageBGRAData- the input BGRA byte data.width- the width of the resultant image.height- the height of the resultant image.- Returns:
- a new direct
ByteBufferof the image's byte data.
-