public class DDSLoader extends java.lang.Object implements AssetLoader
DDSLoader
is an image loader that reads in a DirectX DDS file.
Supports DXT1, DXT3, DXT5, RGB, RGBA, Grayscale, Alpha pixel formats.
2D images, mipmapped 2D images, and cubemaps.Constructor and Description |
---|
DDSLoader() |
Modifier and Type | Method and Description |
---|---|
byte[] |
flipData(byte[] data,
int scanlineSize,
int height)
Flips the given image data on the Y axis.
|
java.lang.Object |
load(AssetInfo info)
Loads asset from the given input stream, parsing it into
an application-usable object.
|
Image |
load(java.io.InputStream stream) |
java.util.ArrayList<java.nio.ByteBuffer> |
readData(boolean flip)
Reads the image data from the InputStream in the required format.
|
java.nio.ByteBuffer |
readDXT2D(boolean flip,
int totalSize)
Reads a DXT compressed image from the InputStream
|
java.nio.ByteBuffer |
readDXT3D(boolean flip,
int totalSize)
Reads a DXT compressed image from the InputStream
|
java.nio.ByteBuffer |
readGrayscale2D(boolean flip,
int totalSize)
Reads a grayscale image with mipmaps from the InputStream
|
java.nio.ByteBuffer |
readGrayscale3D(boolean flip,
int totalSize)
Reads a grayscale image with mipmaps from the InputStream
|
java.nio.ByteBuffer |
readRGB2D(boolean flip,
int totalSize)
Reads an uncompressed RGB or RGBA image.
|
java.nio.ByteBuffer |
readRGB3D(boolean flip,
int totalSize)
Reads an uncompressed RGB or RGBA image.
|
public java.lang.Object load(AssetInfo info) throws java.io.IOException
AssetLoader
load
in interface AssetLoader
java.io.IOException
- If an I/O error occurs while loadingpublic Image load(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public byte[] flipData(byte[] data, int scanlineSize, int height)
data
- Data array containing image data (without mipmaps)scanlineSize
- Size of a single scanline = width * bytesPerPixelheight
- Height of the image in pixelspublic java.nio.ByteBuffer readGrayscale2D(boolean flip, int totalSize) throws java.io.IOException
flip
- Flip the loaded image by Y axistotalSize
- Total size of the image in bytes including the mipmapsjava.io.IOException
- If an error occurred while reading from InputStreampublic java.nio.ByteBuffer readRGB2D(boolean flip, int totalSize) throws java.io.IOException
flip
- Flip the image on the Y axistotalSize
- Size of the image in bytes including mipmapsjava.io.IOException
- If an error occurred while reading from InputStreampublic java.nio.ByteBuffer readDXT2D(boolean flip, int totalSize) throws java.io.IOException
totalSize
- Total size of the image in bytes, including mipmapsjava.io.IOException
- If an error occurred while reading from InputStreampublic java.nio.ByteBuffer readGrayscale3D(boolean flip, int totalSize) throws java.io.IOException
flip
- Flip the loaded image by Y axistotalSize
- Total size of the image in bytes including the mipmapsjava.io.IOException
- If an error occurred while reading from InputStreampublic java.nio.ByteBuffer readRGB3D(boolean flip, int totalSize) throws java.io.IOException
flip
- Flip the image on the Y axistotalSize
- Size of the image in bytes including mipmapsjava.io.IOException
- If an error occurred while reading from InputStreampublic java.nio.ByteBuffer readDXT3D(boolean flip, int totalSize) throws java.io.IOException
totalSize
- Total size of the image in bytes, including mipmapsjava.io.IOException
- If an error occurred while reading from InputStreampublic java.util.ArrayList<java.nio.ByteBuffer> readData(boolean flip) throws java.io.IOException
flip
- Flip the image data or not.
For cubemaps, each of the cubemap faces is flipped individually.
If the image is DXT compressed, no flipping is done.java.io.IOException
- If an error occurred while reading from the stream.