Package com.jme3.texture.plugins
Class DDSLoader
java.lang.Object
com.jme3.texture.plugins.DDSLoader
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]flipData(byte[] data, int scanlineSize, int height) Flips the given image data on the Y axis.Loads asset from the given input stream, parsing it into an application-usable object.load(InputStream stream) readData(boolean flip) Reads the image data from the InputStream in the required format.readDXT2D(boolean flip, int totalSize) Reads a DXT compressed image from the InputStreamreadDXT3D(boolean flip, int totalSize) Reads a DXT compressed image from the InputStreamreadGrayscale2D(boolean flip, int totalSize) Reads a grayscale image with mipmaps from the InputStreamreadGrayscale3D(boolean flip, int totalSize) Reads a grayscale image with mipmaps from the InputStreamreadRGB2D(boolean flip, int totalSize) Reads an uncompressed RGB or RGBA image.readRGB3D(boolean flip, int totalSize) Reads an uncompressed RGB or RGBA image.
-
Constructor Details
-
DDSLoader
public DDSLoader()
-
-
Method Details
-
load
Description copied from interface:AssetLoaderLoads asset from the given input stream, parsing it into an application-usable object.- Specified by:
loadin interfaceAssetLoader- Parameters:
info- the located asset- Returns:
- An object representing the resource.
- Throws:
IOException- If an I/O error occurs while loading
-
load
- Throws:
IOException
-
flipData
public byte[] flipData(byte[] data, int scanlineSize, int height) Flips the given image data on the Y axis.- Parameters:
data- Data array containing image data (without mipmaps)scanlineSize- Size of a single scanline = width * bytesPerPixelheight- Height of the image in pixels- Returns:
- The new data flipped by the Y axis
-
readGrayscale2D
Reads a grayscale image with mipmaps from the InputStream- Parameters:
flip- Flip the loaded image by Y axistotalSize- Total size of the image in bytes including the mipmaps- Returns:
- A ByteBuffer containing the grayscale image data with mips.
- Throws:
IOException- If an error occurred while reading from InputStream
-
readRGB2D
Reads an uncompressed RGB or RGBA image.- Parameters:
flip- Flip the image on the Y axistotalSize- Size of the image in bytes including mipmaps- Returns:
- ByteBuffer containing image data with mipmaps in the format specified by pixelFormat_
- Throws:
IOException- If an error occurred while reading from InputStream
-
readDXT2D
Reads a DXT compressed image from the InputStream- Parameters:
flip- true→flip image along the Y axis, false→don't fliptotalSize- Total size of the image in bytes, including mipmaps- Returns:
- ByteBuffer containing compressed DXT image in the format specified by pixelFormat_
- Throws:
IOException- If an error occurred while reading from InputStream
-
readGrayscale3D
Reads a grayscale image with mipmaps from the InputStream- Parameters:
flip- Flip the loaded image by Y axistotalSize- Total size of the image in bytes including the mipmaps- Returns:
- A ByteBuffer containing the grayscale image data with mips.
- Throws:
IOException- If an error occurred while reading from InputStream
-
readRGB3D
Reads an uncompressed RGB or RGBA image.- Parameters:
flip- Flip the image on the Y axistotalSize- Size of the image in bytes including mipmaps- Returns:
- ByteBuffer containing image data with mipmaps in the format specified by pixelFormat_
- Throws:
IOException- If an error occurred while reading from InputStream
-
readDXT3D
Reads a DXT compressed image from the InputStream- Parameters:
flip- true→flip image along the Y axis, false→don't fliptotalSize- Total size of the image in bytes, including mipmaps- Returns:
- ByteBuffer containing compressed DXT image in the format specified by pixelFormat_
- Throws:
IOException- If an error occurred while reading from InputStream
-
readData
Reads the image data from the InputStream in the required format. If the file contains a cubemap image, it is loaded as 6 ByteBuffers (potentially containing mipmaps if they were specified), otherwise a single ByteBuffer is returned for a 2D image.- Parameters:
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.- Returns:
- An ArrayList containing a single ByteBuffer for a 2D image, or 6 ByteBuffers for a cubemap. The cubemap ByteBuffer order is PositiveX, NegativeX, PositiveY, NegativeY, PositiveZ, NegativeZ.
- Throws:
IOException- If an error occurred while reading from the stream.
-