Class DDSLoader

java.lang.Object
com.jme3.texture.plugins.DDSLoader
All Implemented Interfaces:
AssetLoader

public class DDSLoader extends 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 Details

    • DDSLoader

      public DDSLoader()
  • Method Details

    • load

      public Object load(AssetInfo info) throws IOException
      Description copied from interface: AssetLoader
      Loads asset from the given input stream, parsing it into an application-usable object.
      Specified by:
      load in interface AssetLoader
      Parameters:
      info - the located asset
      Returns:
      An object representing the resource.
      Throws:
      IOException - If an I/O error occurs while loading
    • load

      public Image load(InputStream stream) throws IOException
      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 * bytesPerPixel
      height - Height of the image in pixels
      Returns:
      The new data flipped by the Y axis
    • readGrayscale2D

      public ByteBuffer readGrayscale2D(boolean flip, int totalSize) throws IOException
      Reads a grayscale image with mipmaps from the InputStream
      Parameters:
      flip - Flip the loaded image by Y axis
      totalSize - 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

      public ByteBuffer readRGB2D(boolean flip, int totalSize) throws IOException
      Reads an uncompressed RGB or RGBA image.
      Parameters:
      flip - Flip the image on the Y axis
      totalSize - 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

      public ByteBuffer readDXT2D(boolean flip, int totalSize) throws IOException
      Reads a DXT compressed image from the InputStream
      Parameters:
      flip - true→flip image along the Y axis, false→don't flip
      totalSize - 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

      public ByteBuffer readGrayscale3D(boolean flip, int totalSize) throws IOException
      Reads a grayscale image with mipmaps from the InputStream
      Parameters:
      flip - Flip the loaded image by Y axis
      totalSize - 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

      public ByteBuffer readRGB3D(boolean flip, int totalSize) throws IOException
      Reads an uncompressed RGB or RGBA image.
      Parameters:
      flip - Flip the image on the Y axis
      totalSize - 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

      public ByteBuffer readDXT3D(boolean flip, int totalSize) throws IOException
      Reads a DXT compressed image from the InputStream
      Parameters:
      flip - true→flip image along the Y axis, false→don't flip
      totalSize - 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

      public ArrayList<ByteBuffer> readData(boolean flip) throws IOException
      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.