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
FieldsModifier and TypeFieldDescriptionprotected List<ByteBuffer> protected intprotected ImageDataFormatprotected intprotected int[]protected PixelDataTypeprotected int -
Constructor Summary
ConstructorsConstructorDescriptionImage()Constructor instantiates a newImageobject.Image(ImageDataFormat format, PixelDataType type, int width, int height, ByteBuffer data, int[] mipMapSizes) Constructor instantiates a newImageobject.Image(ImageDataFormat format, PixelDataType type, int width, int height, List<ByteBuffer> data, int[] mipMapSizes) Constructor instantiates a newImageobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddData(ByteBuffer data) Adds the given buffer onto the current list of image databooleangetData()getDatareturns the data for this image.getData(int index) getDatareturns the data for this image at a given index.intintgetDepth()intint[]Returns the mipmap sizes for this image.intgetWidth()booleanReturns whether the image data contains mipmaps.voidread(InputCapsule capsule) voidsetData(int index, ByteBuffer data) voidsetData(ByteBuffer data) setDatasets the data that makes up the image.voidsetData(List<ByteBuffer> data) setDatasets the data that makes up the image.voidsetDataFormat(ImageDataFormat format) voidsetDataType(PixelDataType type) voidsetDepth(int depth) setDepthsets the depth value of the image.voidsetHeight(int height) setHeightsets the height value of the image.voidsetMipMapByteSizes(int[] mipMapSizes) Sets the mipmap data sizes stored in this image's data buffer.voidsetWidth(int width) setWidthsets the width value of the image.voidwrite(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 newImageobject. All values are undefined. -
Image
public Image(ImageDataFormat format, PixelDataType type, int width, int height, List<ByteBuffer> data, int[] mipMapSizes) Constructor instantiates a newImageobject. 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 newImageobject. 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
setDatasets the data that makes up the image. This data is packed into an array ofByteBufferobjects.- Parameters:
data- the data that contains the image information. Must not be null.
-
setData
setDatasets 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) setHeightsets 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) setDepthsets 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) setWidthsets 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
getDatareturns 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
getDatareturns 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:
writein interfaceSavable- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Throws:
IOException
-
getClassTag
- Specified by:
getClassTagin interfaceSavable
-