Class Image

All Implemented Interfaces:
Savable, Cloneable

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.
  • Field Details

    • format

      protected Image.Format format
    • width

      protected int width
    • height

      protected int height
    • depth

      protected int depth
    • mipMapSizes

      protected int[] mipMapSizes
    • data

      protected ArrayList<ByteBuffer> data
    • multiSamples

      protected int multiSamples
    • colorSpace

      protected ColorSpace colorSpace
    • mipsWereGenerated

      protected boolean mipsWereGenerated
    • needGeneratedMips

      protected boolean needGeneratedMips
    • lastTextureState

      protected LastTextureState lastTextureState
  • Constructor Details

  • Method Details

    • getLastTextureState

      public LastTextureState 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.
      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.
      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.
      If mipmaps were generated already.
    • isGeneratedMipmapsRequired

      public boolean isGeneratedMipmapsRequired()
      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.
      setUpdateNeeded in class NativeObject
    • isNPOT

      public boolean isNPOT()
      Determine if the image is NPOT.
      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: NativeObject
      Called when the GL context is restarted to reset all IDs. Prevents "white textures" on display restart.
      Specified by:
      resetObject in class NativeObject
    • deleteNativeBuffers

      protected void deleteNativeBuffers()
      Description copied from class: NativeObject
      Deletes any associated native 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 protected
      deleteNativeBuffers in class NativeObject
    • deleteObject

      public void deleteObject(Object rendererObject)
      Description copied from class: NativeObject
      Deletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.
      Specified by:
      deleteObject in class NativeObject
      rendererObject - The renderer to be used to delete the object
    • createDestructableClone

      public NativeObject createDestructableClone()
      Description copied from class: NativeObject
      Creates a shallow clone of this GL Object. The deleteObject method should be functional for this object.
      Specified by:
      createDestructableClone in class NativeObject
      a new instance
    • getUniqueId

      public long getUniqueId()
      Description copied from class: NativeObject
      Returns a unique ID for this NativeObject. No other NativeObject shall have the same ID.
      Specified by:
      getUniqueId in class NativeObject
      unique ID for this NativeObject.
    • clone

      public Image clone()
      Description copied from class: NativeObject
      This should create a deep clone. For a shallow clone, use createDestructableClone().
      clone in class NativeObject
      A shallow clone of this image. The data is not cloned.
    • getMultiSamples

      public int getMultiSamples()
      The number of samples (for multisampled textures).
      See Also:
    • setMultiSamples

      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).
    • setData

      public void setData(ArrayList<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.
    • setData

      public void setData(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.
    • addData

      public void addData(ByteBuffer data)
    • setData

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

      @Deprecated public Object getEfficentData()
      This feature is no longer used by the engine
    • 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
      mipMapSizes - the mipmap sizes array, or null for a single image map.
    • 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.
      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.
      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.
      width - the width of the image.
    • setFormat

      public void setFormat(Image.Format format)
      setFormat sets the image format for this image.
      format - the image format (not null)
      IllegalArgumentException - if format is null
      See Also:
    • getFormat

      public Image.Format getFormat()
      getFormat returns the image format for this image.
      the image format.
      See Also:
    • getWidth

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

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

      public int getDepth()
      getDepth returns the depth of this image (for 3d images).
      the depth of this image.
    • getData

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

      public ByteBuffer getData(int index)
      getData returns the data for this image. If the data is undefined, null will be returned.
      index - index of the data buffer to access
      the data for this image.
    • hasMipmaps

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

      public int[] getMipMapSizes()
      Returns the mipmap sizes for this image.
      the mipmap sizes for this image.
    • setColorSpace

      public 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. 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.
      colorSpace - Set to sRGB to enable srgb -> linear conversion, Linear otherwise.
      See Also:
    • getColorSpace

      public 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. 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.
      True, if the image is an SRGB image, false if it is linear RGB.
      See Also:
    • toString

      public String toString()
      toString in class NativeObject
    • equals

      public boolean equals(Object other)
      equals in class Object
    • hashCode

      public int hashCode()
      hashCode in class Object
    • write

      public void write(JmeExporter e) throws IOException
      Specified by:
      write in interface Savable
    • read

      public void read(JmeImporter importer) throws IOException
      Specified by:
      read in interface Savable