Package com.ardor3d.image
Class Image
java.lang.Object
com.ardor3d.image.Image
- All Implemented Interfaces:
Savable
,Serializable
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 Summary
Modifier and TypeFieldDescriptionprotected List
<ByteBuffer> protected int
protected ImageDataFormat
protected int
protected int[]
protected PixelDataType
protected int
-
Constructor Summary
ConstructorDescriptionImage()
Constructor instantiates a newImage
object.Image
(ImageDataFormat format, PixelDataType type, int width, int height, ByteBuffer data, int[] mipMapSizes) Constructor instantiates a newImage
object.Image
(ImageDataFormat format, PixelDataType type, int width, int height, List<ByteBuffer> data, int[] mipMapSizes) Constructor instantiates a newImage
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addData
(ByteBuffer data) Adds the given buffer onto the current list of image databoolean
getData()
getData
returns the data for this image.getData
(int index) getData
returns the data for this image at a given index.int
int
getDepth()
int
int[]
Returns the mipmap sizes for this image.int
getWidth()
boolean
Returns whether the image data contains mipmaps.void
read
(InputCapsule capsule) void
setData
(int index, ByteBuffer data) void
setData
(ByteBuffer data) setData
sets the data that makes up the image.void
setData
(List<ByteBuffer> data) setData
sets the data that makes up the image.void
setDataFormat
(ImageDataFormat format) void
setDataType
(PixelDataType type) void
setDepth
(int depth) setDepth
sets the depth value of the image.void
setHeight
(int height) setHeight
sets the height value of the image.void
setMipMapByteSizes
(int[] mipMapSizes) Sets the mipmap data sizes stored in this image's data buffer.void
setWidth
(int width) setWidth
sets the width value of the image.void
write
(OutputCapsule capsule)
-
Field Details
-
_format
-
_type
-
_width
protected int _width -
_height
protected int _height -
_depth
protected int _depth -
_mipMapSizes
protected int[] _mipMapSizes -
_data
-
-
Constructor Details
-
Image
public Image()Constructor instantiates a newImage
object. All values are undefined. -
Image
public Image(ImageDataFormat format, PixelDataType type, int width, int height, List<ByteBuffer> data, int[] mipMapSizes) Constructor instantiates a newImage
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 newImage
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
setData
sets the data that makes up the image. This data is packed into an array ofByteBuffer
objects.- Parameters:
data
- the data that contains the image information. Must not be null.
-
setData
setData
sets the data that makes up the image. This data is packed into a singleByteBuffer
.- Parameters:
data
- the data that contains the image information.
-
addData
Adds the given buffer onto the current list of image data- Parameters:
data
- the data that contains the image information.
-
setData
-
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
- Parameters:
format
- the image data format.- Throws:
NullPointerException
- if format is null- See Also:
-
getDataFormat
- Returns:
- the image data format.
- See Also:
-
setDataType
- Parameters:
type
- the image data type.- Throws:
NullPointerException
- if type is null- See Also:
-
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
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
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
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-