Class Image

java.lang.Object
com.ardor3d.image.Image
All Implemented Interfaces:
Savable, Serializable

public class Image extends Object implements Serializable, Savable
Image defines a data format for a graphical image. The image is defined by a format, a height and width, and the image data. The width and height must be greater than 0. The data is contained in a byte buffer, and should be packed before creation of the image object.
See Also:
  • Field Details

    • _format

      protected ImageDataFormat _format
    • _type

      protected PixelDataType _type
    • _width

      protected int _width
    • _height

      protected int _height
    • _depth

      protected int _depth
    • _mipMapSizes

      protected int[] _mipMapSizes
    • _data

      protected List<ByteBuffer> _data
  • Constructor Details

    • Image

      public Image()
      Constructor instantiates a new Image object. All values are undefined.
    • Image

      public Image(ImageDataFormat format, PixelDataType type, int width, int height, List<ByteBuffer> data, int[] mipMapSizes)
      Constructor instantiates a new Image object. The attributes of the image are defined during construction.
      Parameters:
      format - the data format of the image. Must not be null.
      type - the data type of the image. Must not be null.
      width - the width of the image.
      height - the height of the image.
      data - the image data. Must not be null.
      mipMapSizes - the array of mipmap sizes, or null for no mipmaps.
    • Image

      public Image(ImageDataFormat format, PixelDataType type, int width, int height, ByteBuffer data, int[] mipMapSizes)
      Constructor instantiates a new Image object. The attributes of the image are defined during construction.
      Parameters:
      format - the data format of the image. Must not be null.
      type - the data type of the image. Must not be null.
      width - the width of the image.
      height - the height of the image.
      data - the image data. Must not be null.
      mipMapSizes - the array of mipmap sizes, or null for no mipmaps.
  • Method Details

    • setData

      public void setData(List<ByteBuffer> data)
      setData sets the data that makes up the image. This data is packed into an array of ByteBuffer objects.
      Parameters:
      data - the data that contains the image information. Must not be null.
    • setData

      public void setData(ByteBuffer data)
      setData sets the data that makes up the image. This data is packed into a single ByteBuffer.
      Parameters:
      data - the data that contains the image information.
    • addData

      public void addData(ByteBuffer data)
      Adds the given buffer onto the current list of image data
      Parameters:
      data - the data that contains the image information.
    • setData

      public void setData(int index, ByteBuffer data)
    • setMipMapByteSizes

      public void setMipMapByteSizes(int[] mipMapSizes)
      Sets the mipmap data sizes stored in this image's data buffer. Mipmaps are stored sequentially, and the first mipmap is the main image data. To specify no mipmaps, pass null.
      Parameters:
      mipMapSizes - the mipmap sizes array, or null to indicate no mip maps.
    • setHeight

      public void setHeight(int height)
      setHeight sets the height value of the image. It is typically a good idea to try to keep this as a multiple of 2.
      Parameters:
      height - the height of the image.
    • setDepth

      public void setDepth(int depth)
      setDepth sets the depth value of the image. It is typically a good idea to try to keep this as a multiple of 2. This is used for 3d images.
      Parameters:
      depth - the depth of the image.
    • setWidth

      public void setWidth(int width)
      setWidth sets the width value of the image. It is typically a good idea to try to keep this as a multiple of 2.
      Parameters:
      width - the width of the image.
    • setDataFormat

      public void setDataFormat(ImageDataFormat format)
      Parameters:
      format - the image data format.
      Throws:
      NullPointerException - if format is null
      See Also:
    • getDataFormat

      public ImageDataFormat getDataFormat()
      Returns:
      the image data format.
      See Also:
    • setDataType

      public void setDataType(PixelDataType type)
      Parameters:
      type - the image data type.
      Throws:
      NullPointerException - if type is null
      See Also:
    • getDataType

      public PixelDataType getDataType()
      Returns:
      the image data type.
      See Also:
    • getWidth

      public int getWidth()
      Returns:
      the width of this image.
    • getHeight

      public int getHeight()
      Returns:
      the height of this image.
    • getDepth

      public int getDepth()
      Returns:
      the depth of this image (used for 3d textures and 2d texture arrays)
    • getData

      public List<ByteBuffer> getData()
      getData returns the data for this image. If the data is undefined, null will be returned.
      Returns:
      the data for this image.
    • getDataSize

      public int getDataSize()
      Returns:
      the number of individual data buffers or slices in this Image.
    • getData

      public ByteBuffer getData(int index)
      getData returns the data for this image at a given index. If the data is undefined, null will be returned.
      Parameters:
      index - the index of the image
      Returns:
      the data for this image.
    • hasMipmaps

      public boolean hasMipmaps()
      Returns whether the image data contains mipmaps.
      Returns:
      true if the image data contains mipmaps, false if not.
    • getMipMapByteSizes

      public int[] getMipMapByteSizes()
      Returns the mipmap sizes for this image.
      Returns:
      the mipmap sizes for this image.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • getClassTag

      public Class<? extends Image> getClassTag()
      Specified by:
      getClassTag in interface Savable