Package com.jme3.texture
Class Image
java.lang.Object
com.jme3.util.NativeObject
com.jme3.texture.Image
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.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ColorSpaceprotected ArrayList<ByteBuffer> protected intprotected Image.Formatprotected intprotected LastTextureStateprotected int[]protected booleanprotected intprotected booleanprotected intFields inherited from class com.jme3.util.NativeObject
handleRef, id, INVALID_ID, objectManager, OBJTYPE_AUDIOBUFFER, OBJTYPE_AUDIOSTREAM, OBJTYPE_BO, OBJTYPE_FILTER, OBJTYPE_FRAMEBUFFER, OBJTYPE_SHADER, OBJTYPE_SHADERSOURCE, OBJTYPE_TEXTURE, OBJTYPE_VERTEXBUFFER, updateNeeded -
Constructor Summary
ConstructorsModifierConstructorDescriptionImage()Constructor instantiates a newImageobject.protectedImage(int id) Image(Image.Format format, int width, int height, int depth, ArrayList<ByteBuffer> data) Deprecated.Image(Image.Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, int[] mipMapSizes) Image(Image.Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, int[] mipMapSizes, ColorSpace colorSpace) Constructor instantiates a newImageobject.Image(Image.Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, ColorSpace colorSpace) Constructor instantiates a newImageobject.Image(Image.Format format, int width, int height, ByteBuffer data) Image(Image.Format format, int width, int height, ByteBuffer data, int[] mipMapSizes) Image(Image.Format format, int width, int height, ByteBuffer data, int[] mipMapSizes, ColorSpace colorSpace) Constructor instantiates a newImageobject.Image(Image.Format format, int width, int height, ByteBuffer data, ColorSpace colorSpace) Constructor instantiates a newImageobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddData(ByteBuffer data) clone()This should create a deep clone.Creates a shallow clone of this GL Object.protected voidDeletes any associated nativebuffers.voiddeleteObject(Object rendererObject) Deletes the GL object from the GPU when it is no longer used.booleanSpecifies 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 theRenderer.setLinearizeSrgbImages(boolean)option is enabled.getData()getDatareturns the data for this image.getData(int index) getDatareturns the data for this image.intgetDepth()getDepthreturns the depth of this image (for 3d images).Deprecated.This feature is no longer used by the enginegetFormatreturns the image format for this image.intgetHeightreturns the height of this image.Internal use only.int[]Returns the mipmap sizes for this image.intlongReturns a unique ID for this NativeObject.intgetWidth()getWidthreturns the width of this image.inthashCode()booleanReturns whether the image data contains mipmaps.booleanbooleanInternal use only.booleanisNPOT()Determine if the image is NPOT.voidread(JmeImporter importer) voidCalled when the GL context is restarted to reset all IDs.voidsetColorSpace(ColorSpace colorSpace) image loader is responsible for setting this attribute based on the color space in which the image has been encoded with.voidsetData(int index, ByteBuffer data) voidsetData(ByteBuffer data) setDatasets the data that makes up the image.voidsetData(ArrayList<ByteBuffer> data) setDatasets the data that makes up the image.voidsetDepth(int depth) setDepthsets the depth value of the image.voidsetFormat(Image.Format format) setFormatsets the image format for this image.voidsetHeight(int height) setHeightsets the height value of the image.voidsetMipmapsGenerated(boolean generated) Internal use only.voidsetMipMapSizes(int[] mipMapSizes) Sets the mipmap sizes stored in this image's data buffer.voidsetMultiSamples(int multiSamples) voidSets the update needed flag, while also checking if mipmaps need to be regenerated.voidsetWidth(int width) setWidthsets the width value of the image.toString()voidwrite(JmeExporter e) Methods inherited from class com.jme3.util.NativeObject
clearUpdateNeeded, dispose, getId, getWeakRef, isUpdateNeeded, setId
-
Field Details
-
format
-
width
protected int width -
height
protected int height -
depth
protected int depth -
mipMapSizes
protected int[] mipMapSizes -
data
-
multiSamples
protected int multiSamples -
colorSpace
-
mipsWereGenerated
protected boolean mipsWereGenerated -
needGeneratedMips
protected boolean needGeneratedMips -
lastTextureState
-
-
Constructor Details
-
Image
public Image()Constructor instantiates a newImageobject. All values are undefined. -
Image
protected Image(int id) -
Image
public Image(Image.Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, int[] mipMapSizes, ColorSpace colorSpace) Constructor instantiates a newImageobject. The attributes of the image are defined during construction.- Parameters:
format- the data format of the image.width- the width of the image.height- the height of the image.depth- the desired image depthdata- the image data.mipMapSizes- the array of mipmap sizes, or null for no mipmaps.colorSpace- the colorSpace of the image
-
Image
@Deprecated public Image(Image.Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, int[] mipMapSizes) Deprecated.- Parameters:
format- the desired data formatwidth- the desired width (in pixels)height- the desired height (in pixels)depth- the desired image depthdata- the image data to usemipMapSizes- the desired mipmap sizes, or null for no mipmaps- See Also:
-
Image
public Image(Image.Format format, int width, int height, ByteBuffer data, int[] mipMapSizes, ColorSpace colorSpace) Constructor instantiates a newImageobject. The attributes of the image are defined during construction.- Parameters:
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
-
Image
@Deprecated public Image(Image.Format format, int width, int height, ByteBuffer data, int[] mipMapSizes) Deprecated.- Parameters:
format- the desired data formatwidth- the desired width (in pixels)height- the desired height (in pixels)data- the image data to usemipMapSizes- the desired mipmap sizes, or null for no mipmaps- See Also:
-
Image
public Image(Image.Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, ColorSpace colorSpace) Constructor instantiates a newImageobject. The attributes of the image are defined during construction.- Parameters:
format- the data format of the image.width- the width of the image.height- the height of the image.depth- the desired image depthdata- the image data.colorSpace- the colorSpace of the image
-
Image
@Deprecated public Image(Image.Format format, int width, int height, int depth, ArrayList<ByteBuffer> data) Deprecated.- Parameters:
format- the desired data formatwidth- the desired width (in pixels)height- the desired height (in pixels)depth- the desired image depthdata- the image data to use- See Also:
-
Image
Constructor instantiates a newImageobject. The attributes of the image are defined during construction.- Parameters:
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
-
Image
Deprecated.- Parameters:
format- the desired data formatwidth- the desired width (in pixels)height- the desired height (in pixels)data- the image data- See Also:
-
-
Method Details
-
getLastTextureState
Internal use only. The renderer stores the texture state set from the last texture, so it doesn't have to change it unless necessary.- Returns:
- The image parameter state.
-
setMipmapsGenerated
public void setMipmapsGenerated(boolean generated) Internal use only. The renderer marks which images have generated mipmaps in VRAM and which do not, so it can generate them as needed.- Parameters:
generated- If mipmaps were generated or not.
-
isMipmapsGenerated
public boolean isMipmapsGenerated()Internal use only. Check if the renderer has generated mipmaps for this image in VRAM or not.- Returns:
- If mipmaps were generated already.
-
isGeneratedMipmapsRequired
public boolean isGeneratedMipmapsRequired()- Returns:
- True if the image needs to have mipmaps generated for it (as requested by the texture). This stays true even after mipmaps have been generated.
-
setUpdateNeeded
public void setUpdateNeeded()Sets the update needed flag, while also checking if mipmaps need to be regenerated.- Overrides:
setUpdateNeededin classNativeObject
-
isNPOT
public boolean isNPOT()Determine if the image is NPOT.- Returns:
- if the image is a non-power-of-2 image, e.g. having dimensions that are not powers of 2.
-
resetObject
public void resetObject()Description copied from class:NativeObjectCalled when the GL context is restarted to reset all IDs. Prevents "white textures" on display restart.- Specified by:
resetObjectin classNativeObject
-
deleteNativeBuffers
protected void deleteNativeBuffers()Description copied from class:NativeObjectDeletes any associated nativebuffers. 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 protected- Overrides:
deleteNativeBuffersin classNativeObject
-
deleteObject
Description copied from class:NativeObjectDeletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.- Specified by:
deleteObjectin classNativeObject- Parameters:
rendererObject- The renderer to be used to delete the object
-
createDestructableClone
Description copied from class:NativeObjectCreates a shallow clone of this GL Object. The deleteObject method should be functional for this object.- Specified by:
createDestructableClonein classNativeObject- Returns:
- a new instance
-
getUniqueId
public long getUniqueId()Description copied from class:NativeObjectReturns a unique ID for this NativeObject. No other NativeObject shall have the same ID.- Specified by:
getUniqueIdin classNativeObject- Returns:
- unique ID for this NativeObject.
-
clone
Description copied from class:NativeObjectThis should create a deep clone. For a shallow clone, use createDestructableClone().- Overrides:
clonein classNativeObject- Returns:
- A shallow clone of this image. The data is not cloned.
-
getMultiSamples
public int getMultiSamples()- Returns:
- The number of samples (for multisampled textures).
- See Also:
-
setMultiSamples
public void setMultiSamples(int multiSamples) - Parameters:
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).
-
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.
-
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
-
setData
-
getEfficentData
Deprecated.This feature is no longer used by the engine- Returns:
- null
-
setMipMapSizes
public void setMipMapSizes(int[] mipMapSizes) Sets the mipmap 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 and this will automatically be expanded into a single mipmap of the full- Parameters:
mipMapSizes- the mipmap sizes array, or null for a single image map.
-
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.
-
setFormat
setFormatsets the image format for this image.- Parameters:
format- the image format (not null)- Throws:
IllegalArgumentException- if format is null- See Also:
-
getFormat
getFormatreturns the image format for this image.- Returns:
- the image format.
- See Also:
-
getWidth
public int getWidth()getWidthreturns the width of this image.- Returns:
- the width of this image.
-
getHeight
public int getHeight()getHeightreturns the height of this image.- Returns:
- the height of this image.
-
getDepth
public int getDepth()getDepthreturns the depth of this image (for 3d images).- Returns:
- the depth of this image.
-
getData
getDatareturns the data for this image. If the data is undefined, null will be returned.- Returns:
- the data for this image.
-
getData
getDatareturns the data for this image. If the data is undefined, null will be returned.- Parameters:
index- index of the data buffer to access- 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.
-
getMipMapSizes
public int[] getMipMapSizes()Returns the mipmap sizes for this image.- Returns:
- the mipmap sizes for this image.
-
setColorSpace
image loader is responsible for setting this attribute based on the color space in which the image has been encoded with. In the majority of cases, this flag will be set to sRGB by default since many image formats do not contain any color space information and the most frequently used colors space is sRGB The material loader may override this attribute to Linear if it determines that such conversion must not be performed, for example, when loading normal maps.- Parameters:
colorSpace- Set to sRGB to enable srgb -> linear conversion, Linear otherwise.- See Also:
-
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 theRenderer.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.- Returns:
- True, if the image is an SRGB image, false if it is linear RGB.
- See Also:
-
toString
- Overrides:
toStringin classNativeObject
-
equals
-
hashCode
public int hashCode() -
write
- Specified by:
writein interfaceSavable- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Throws:
IOException
-
Image(com.jme3.texture.Image.Format, int, int, int, java.util.ArrayList, com.jme3.texture.image.ColorSpace)