public class Image extends NativeObject implements 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.Modifier and Type | Class and Description |
---|---|
static class |
Image.Format |
Modifier and Type | Field and Description |
---|---|
protected ColorSpace |
colorSpace |
protected java.util.ArrayList<java.nio.ByteBuffer> |
data |
protected int |
depth |
protected Image.Format |
format |
protected int |
height |
protected LastTextureState |
lastTextureState |
protected int[] |
mipMapSizes |
protected boolean |
mipsWereGenerated |
protected int |
multiSamples |
protected boolean |
needGeneratedMips |
protected int |
width |
handleRef, id, INVALID_ID, objectManager, OBJTYPE_AUDIOBUFFER, OBJTYPE_AUDIOSTREAM, OBJTYPE_BO, OBJTYPE_FILTER, OBJTYPE_FRAMEBUFFER, OBJTYPE_SHADER, OBJTYPE_SHADERSOURCE, OBJTYPE_TEXTURE, OBJTYPE_VERTEXBUFFER, updateNeeded
Modifier | Constructor and Description |
---|---|
|
Image()
Constructor instantiates a new
Image object. |
|
Image(Image.Format format,
int width,
int height,
java.nio.ByteBuffer data)
|
|
Image(Image.Format format,
int width,
int height,
java.nio.ByteBuffer data,
ColorSpace colorSpace)
Constructor instantiates a new
Image object. |
|
Image(Image.Format format,
int width,
int height,
java.nio.ByteBuffer data,
int[] mipMapSizes)
|
|
Image(Image.Format format,
int width,
int height,
java.nio.ByteBuffer data,
int[] mipMapSizes,
ColorSpace colorSpace)
Constructor instantiates a new
Image object. |
|
Image(Image.Format format,
int width,
int height,
int depth,
java.util.ArrayList<java.nio.ByteBuffer> data)
|
|
Image(Image.Format format,
int width,
int height,
int depth,
java.util.ArrayList<java.nio.ByteBuffer> data,
ColorSpace colorSpace)
Constructor instantiates a new
Image object. |
|
Image(Image.Format format,
int width,
int height,
int depth,
java.util.ArrayList<java.nio.ByteBuffer> data,
int[] mipMapSizes)
|
|
Image(Image.Format format,
int width,
int height,
int depth,
java.util.ArrayList<java.nio.ByteBuffer> data,
int[] mipMapSizes,
ColorSpace colorSpace)
Constructor instantiates a new
Image object. |
protected |
Image(int id) |
Modifier and Type | Method and Description |
---|---|
void |
addData(java.nio.ByteBuffer data) |
Image |
clone()
This should create a deep clone.
|
NativeObject |
createDestructableClone()
Creates a shallow clone of this GL Object.
|
protected void |
deleteNativeBuffers()
Deletes any associated native
buffers . |
void |
deleteObject(java.lang.Object rendererObject)
Deletes the GL object from the GPU when it is no longer used.
|
boolean |
equals(java.lang.Object other) |
ColorSpace |
getColorSpace()
Specifies that this image is an SRGB image and therefore must undergo an
sRGB -> linear RGB color conversion prior to being read by a shader and
with the
Renderer.setLinearizeSrgbImages(boolean) option is
enabled. |
java.util.List<java.nio.ByteBuffer> |
getData()
getData returns the data for this image. |
java.nio.ByteBuffer |
getData(int index)
getData returns the data for this image. |
int |
getDepth()
getDepth returns the depth of this image (for 3d images). |
java.lang.Object |
getEfficentData()
Deprecated.
This feature is no longer used by the engine
|
Image.Format |
getFormat()
getFormat returns the image format for this image. |
int |
getHeight()
getHeight returns the height of this image. |
LastTextureState |
getLastTextureState()
Internal use only.
|
int[] |
getMipMapSizes()
Returns the mipmap sizes for this image.
|
int |
getMultiSamples() |
long |
getUniqueId()
Returns a unique ID for this NativeObject.
|
int |
getWidth()
getWidth returns the width of this image. |
int |
hashCode() |
boolean |
hasMipmaps()
Returns whether the image data contains mipmaps.
|
boolean |
isGeneratedMipmapsRequired() |
boolean |
isMipmapsGenerated()
Internal use only.
|
boolean |
isNPOT()
Determine if the image is NPOT.
|
void |
read(JmeImporter e) |
void |
resetObject()
Called when the GL context is restarted to reset all IDs.
|
void |
setColorSpace(ColorSpace colorSpace)
image loader is responsible for setting this attribute based on the color
space in which the image has been encoded with.
|
void |
setData(java.util.ArrayList<java.nio.ByteBuffer> data)
setData sets the data that makes up the image. |
void |
setData(java.nio.ByteBuffer data)
setData sets the data that makes up the image. |
void |
setData(int index,
java.nio.ByteBuffer data) |
void |
setDepth(int depth)
setDepth sets the depth value of the image. |
void |
setEfficentData(java.lang.Object efficientData)
Deprecated.
This feature is no longer used by the engine
|
void |
setFormat(Image.Format format)
setFormat sets the image format for this image. |
void |
setHeight(int height)
setHeight sets the height value of the image. |
void |
setMipmapsGenerated(boolean generated)
Internal use only.
|
void |
setMipMapSizes(int[] mipMapSizes)
Sets the mipmap sizes stored in this image's data buffer.
|
void |
setMultiSamples(int multiSamples) |
void |
setUpdateNeeded()
Sets the update needed flag, while also checking if mipmaps
need to be regenerated.
|
void |
setWidth(int width)
setWidth sets the width value of the image. |
java.lang.String |
toString() |
void |
write(JmeExporter e) |
clearUpdateNeeded, dispose, getId, getWeakRef, isUpdateNeeded, setId
protected Image.Format format
protected int width
protected int height
protected int depth
protected int[] mipMapSizes
protected java.util.ArrayList<java.nio.ByteBuffer> data
protected int multiSamples
protected ColorSpace colorSpace
protected boolean mipsWereGenerated
protected boolean needGeneratedMips
protected LastTextureState lastTextureState
public Image()
Image
object. All values
are undefined.protected Image(int id)
public Image(Image.Format format, int width, int height, int depth, java.util.ArrayList<java.nio.ByteBuffer> data, int[] mipMapSizes, ColorSpace colorSpace)
Image
object. The
attributes of the image are defined during construction.format
- the data format of the image.width
- the width of the image.height
- the height of the image.data
- the image data.mipMapSizes
- the array of mipmap sizes, or null for no mipmaps.colorSpace
- the colorSpace of the image
@Deprecated public Image(Image.Format format, int width, int height, int depth, java.util.ArrayList<java.nio.ByteBuffer> data, int[] mipMapSizes)
Image(com.jme3.texture.Image.Format, int, int, int, java.util.ArrayList, int[], com.jme3.texture.image.ColorSpace)
format
- width
- height
- depth
- data
- mipMapSizes
- Image(com.jme3.texture.Image.Format, int, int, int, java.util.ArrayList, int[], com.jme3.texture.image.ColorSpace)
public Image(Image.Format format, int width, int height, java.nio.ByteBuffer data, int[] mipMapSizes, ColorSpace colorSpace)
Image
object. The
attributes of the image are defined during construction.format
- the data format of the image.width
- the width of the image.height
- the height of the image.data
- the image data.mipMapSizes
- the array of mipmap sizes, or null for no mipmaps.colorSpace
- the colorSpace of the image
@Deprecated public Image(Image.Format format, int width, int height, java.nio.ByteBuffer data, int[] mipMapSizes)
Image(com.jme3.texture.Image.Format, int, int, java.nio.ByteBuffer, int[], com.jme3.texture.image.ColorSpace)
format
- width
- height
- data
- mipMapSizes
- Image(com.jme3.texture.Image.Format, int, int, java.nio.ByteBuffer, int[], com.jme3.texture.image.ColorSpace)
public Image(Image.Format format, int width, int height, int depth, java.util.ArrayList<java.nio.ByteBuffer> data, ColorSpace colorSpace)
Image
object. The
attributes of the image are defined during construction.format
- the data format of the image.width
- the width of the image.height
- the height of the image.data
- the image data.colorSpace
- the colorSpace of the image
@Deprecated public Image(Image.Format format, int width, int height, int depth, java.util.ArrayList<java.nio.ByteBuffer> data)
Image(com.jme3.texture.Image.Format, int, int, int, java.util.ArrayList, com.jme3.texture.image.ColorSpace)
format
- width
- height
- depth
- data
- Image(com.jme3.texture.Image.Format, int, int, int, java.util.ArrayList, com.jme3.texture.image.ColorSpace)
public Image(Image.Format format, int width, int height, java.nio.ByteBuffer data, ColorSpace colorSpace)
Image
object. The
attributes of the image are defined during construction.format
- the data format of the image.width
- the width of the image.height
- the height of the image.data
- the image data.colorSpace
- the colorSpace of the image
@Deprecated public Image(Image.Format format, int width, int height, java.nio.ByteBuffer data)
Image(com.jme3.texture.Image.Format, int, int, java.nio.ByteBuffer, com.jme3.texture.image.ColorSpace)
format
- width
- height
- data
- Image(com.jme3.texture.Image.Format, int, int, java.nio.ByteBuffer, com.jme3.texture.image.ColorSpace)
public LastTextureState getLastTextureState()
public void setMipmapsGenerated(boolean generated)
generated
- If mipmaps were generated or not.public boolean isMipmapsGenerated()
public boolean isGeneratedMipmapsRequired()
public void setUpdateNeeded()
setUpdateNeeded
in class NativeObject
public boolean isNPOT()
public void resetObject()
NativeObject
resetObject
in class NativeObject
protected void deleteNativeBuffers()
NativeObject
buffers
.
This is necessary because it is unlikely that native buffers
will be garbage collected naturally (due to how GC works), therefore
the collection must be handled manually.
Only implementations that manage native buffers need to override
this method. Note that the behavior that occurs when a
deleted native buffer is used is not defined, therefore this
method is protecteddeleteNativeBuffers
in class NativeObject
public void deleteObject(java.lang.Object rendererObject)
NativeObject
deleteObject
in class NativeObject
rendererObject
- The renderer to be used to delete the objectpublic NativeObject createDestructableClone()
NativeObject
createDestructableClone
in class NativeObject
public long getUniqueId()
NativeObject
getUniqueId
in class NativeObject
public Image clone()
NativeObject
clone
in class NativeObject
public int getMultiSamples()
setMultiSamples(int)
public void setMultiSamples(int multiSamples)
multiSamples
- Set the number of samples to use for this image,
setting this to a value higher than 1 turns this image/texture
into a multisample texture (on OpenGL3.1 and higher).public void setData(java.util.ArrayList<java.nio.ByteBuffer> data)
setData
sets the data that makes up the image. This data
is packed into an array of ByteBuffer
objects.data
- the data that contains the image information.public void setData(java.nio.ByteBuffer data)
setData
sets the data that makes up the image. This data
is packed into a single ByteBuffer
.data
- the data that contains the image information.public void addData(java.nio.ByteBuffer data)
public void setData(int index, java.nio.ByteBuffer data)
@Deprecated public void setEfficentData(java.lang.Object efficientData)
@Deprecated public java.lang.Object getEfficentData()
public void setMipMapSizes(int[] mipMapSizes)
mipMapSizes
- the mipmap sizes array, or null for a single image map.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.height
- the height of the image.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.depth
- the depth of the image.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.width
- the width of the image.public void setFormat(Image.Format format)
setFormat
sets the image format for this image.format
- the image format.java.lang.NullPointerException
- if format is nullImage.Format
public Image.Format getFormat()
getFormat
returns the image format for this image.Image.Format
public int getWidth()
getWidth
returns the width of this image.public int getHeight()
getHeight
returns the height of this image.public int getDepth()
getDepth
returns the depth of this image (for 3d images).public java.util.List<java.nio.ByteBuffer> getData()
getData
returns the data for this image. If the data is
undefined, null will be returned.public java.nio.ByteBuffer getData(int index)
getData
returns the data for this image. If the data is
undefined, null will be returned.public boolean hasMipmaps()
public int[] getMipMapSizes()
public void setColorSpace(ColorSpace colorSpace)
colorSpace
- Set to sRGB to enable srgb -> linear
conversion, Linear otherwise.Renderer.setLinearizeSrgbImages(boolean)
public ColorSpace getColorSpace()
Renderer.setLinearizeSrgbImages(boolean)
option is
enabled.
This option is only supported for the 8-bit color and grayscale image
formats. Determines if the image is in SRGB color space or not.Renderer.setLinearizeSrgbImages(boolean)
public java.lang.String toString()
toString
in class NativeObject
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void write(JmeExporter e) throws java.io.IOException
public void read(JmeImporter e) throws java.io.IOException