com.jme.image
Class Image

java.lang.Object
  extended bycom.jme.image.Image

public class Image
extends java.lang.Object

Image defines a data format for a graphical image. The image is defined by a type, a height and width, and the image data. The type can be any one of the following types: RGBA4444, RGB888, RGBA5551, RGBA8888. 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.

Version:
$Id: Image.java,v 1.8 2005/02/18 18:28:02 renanse Exp $
Author:
Mark Powell

Field Summary
protected  java.nio.ByteBuffer data
           
static int DXT1_NATIVE
          DXT-1 compressed format, no alpha.
static int DXT1A_NATIVE
          DXT-1 compressed format, one bit alpha.
static int DXT3_NATIVE
          DXT-3 compressed format, with alpha.
static int DXT5_NATIVE
          DXT-5 compressed format, with alpha.
static int GUESS_FORMAT
          When used in texture loading, this indicates to let jME guess the format.
static int GUESS_FORMAT_NO_S3TC
          When used in texture loading, this indicates to let jME guess the format, but not to use S3TC compression, even if available.
protected  int height
           
static int LAST_TYPE
           
static int LAST_UNCOMPRESSED_TYPE
           
protected  int[] mipMapSizes_
           
static int RA88
          16-bit RA with 8 bits for red and 8 bits for alpha.
static int RGB888
          24-bit RGB with 8 bits for each component.
static int RGB888_DXT1
          RGB888, compressed to DXT-1 internally.
static int RGBA4444
          16-bit RGBA with 4 bits for each component.
static int RGBA5551
          16-bit RGBA with 5 bits for color components and 1 bit for alpha.
static int RGBA8888
          32-bit RGBA with 8 bits for each component.
static int RGBA8888_DXT1A
          RGBA8888, compressed to DXT-1A internally.
static int RGBA8888_DXT3
          RGBA8888, compressed to DXT-3 internally.
static int RGBA8888_DXT5
          RGBA8888, compressed to DXT-5 internally.
protected  int type
           
protected  int width
           
 
Constructor Summary
Image()
          Constructor instantiates a new Image object.
Image(int type, int width, int height, java.nio.ByteBuffer data)
          Constructor instantiates a new Image object.
Image(int type, int width, int height, java.nio.ByteBuffer data, int[] mipMapSizes)
          Constructor instantiates a new Image object.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 java.nio.ByteBuffer getData()
          getData returns the data for this image.
 int getHeight()
          getHeight returns the height of this image.
 int[] getMipMapSizes()
          Returns the mipmap sizes for this image.
 int getType()
          getType returns the image format for this image.
 int getWidth()
          getWidth returns the width of this image.
 boolean hasMipmaps()
          Returns whether the image data contains mipmaps.
 boolean isCompressedType()
          Returns whether the image type is compressed.
 void setData(java.nio.ByteBuffer data)
          setData sets the data that makes up the image.
 void setHeight(int height)
          setHeight sets the height value of the image.
 void setMipMapSizes(int[] mipMapSizes)
          Sets the mipmap sizes stored in this image's data buffer.
 void setType(int type)
          setType sets the image format for this image.
 void setWidth(int width)
          setWidth sets the width value of the image.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GUESS_FORMAT_NO_S3TC

public static final int GUESS_FORMAT_NO_S3TC
When used in texture loading, this indicates to let jME guess the format, but not to use S3TC compression, even if available.

See Also:
Constant Field Values

GUESS_FORMAT

public static final int GUESS_FORMAT
When used in texture loading, this indicates to let jME guess the format. jME will use S3TC compression, if available.

See Also:
Constant Field Values

RGBA4444

public static final int RGBA4444
16-bit RGBA with 4 bits for each component.

See Also:
Constant Field Values

RGB888

public static final int RGB888
24-bit RGB with 8 bits for each component.

See Also:
Constant Field Values

RGBA5551

public static final int RGBA5551
16-bit RGBA with 5 bits for color components and 1 bit for alpha.

See Also:
Constant Field Values

RGBA8888

public static final int RGBA8888
32-bit RGBA with 8 bits for each component.

See Also:
Constant Field Values

RA88

public static final int RA88
16-bit RA with 8 bits for red and 8 bits for alpha.

See Also:
Constant Field Values

RGB888_DXT1

public static final int RGB888_DXT1
RGB888, compressed to DXT-1 internally.

See Also:
Constant Field Values

RGBA8888_DXT1A

public static final int RGBA8888_DXT1A
RGBA8888, compressed to DXT-1A internally.

See Also:
Constant Field Values

RGBA8888_DXT3

public static final int RGBA8888_DXT3
RGBA8888, compressed to DXT-3 internally.

See Also:
Constant Field Values

RGBA8888_DXT5

public static final int RGBA8888_DXT5
RGBA8888, compressed to DXT-5 internally.

See Also:
Constant Field Values

LAST_UNCOMPRESSED_TYPE

public static final int LAST_UNCOMPRESSED_TYPE
See Also:
Constant Field Values

DXT1_NATIVE

public static final int DXT1_NATIVE
DXT-1 compressed format, no alpha.

See Also:
Constant Field Values

DXT1A_NATIVE

public static final int DXT1A_NATIVE
DXT-1 compressed format, one bit alpha.

See Also:
Constant Field Values

DXT3_NATIVE

public static final int DXT3_NATIVE
DXT-3 compressed format, with alpha.

See Also:
Constant Field Values

DXT5_NATIVE

public static final int DXT5_NATIVE
DXT-5 compressed format, with alpha.

See Also:
Constant Field Values

LAST_TYPE

public static final int LAST_TYPE
See Also:
Constant Field Values

type

protected int type

width

protected int width

height

protected int height

mipMapSizes_

protected int[] mipMapSizes_

data

protected java.nio.ByteBuffer data
Constructor Detail

Image

public Image()
Constructor instantiates a new Image object. All values are undefined.


Image

public Image(int type,
             int width,
             int height,
             java.nio.ByteBuffer data,
             int[] mipMapSizes)
Constructor instantiates a new Image object. The attributes of the image are defined during construction.

Parameters:
type - the type of image format.
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.

Image

public Image(int type,
             int width,
             int height,
             java.nio.ByteBuffer data)
Constructor instantiates a new Image object. The attributes of the image are defined during construction.

Parameters:
type - the type of image format.
width - the width of the image.
height - the height of the image.
data - the image data.
Method Detail

setData

public void setData(java.nio.ByteBuffer data)
setData sets the data that makes up the image. This data is packed into a single ByteBuffer.

Parameters:
data - the data that contains the image information.

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

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.

setType

public void setType(int type)
setType sets the image format for this image. If an invalid value is passed, the type defaults to RGBA4444.

Parameters:
type - the image format.

getType

public int getType()
getType returns the image format for this image.

Returns:
the image format.

isCompressedType

public boolean isCompressedType()
Returns whether the image type is compressed.

Returns:
true if the image type is compressed, false otherwise.

getWidth

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

Returns:
the width of this image.

getHeight

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

Returns:
the height of this image.

getData

public java.nio.ByteBuffer getData()
getData returns the data for this image. If the data is undefined, null will be returned.

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.

equals

public boolean equals(java.lang.Object other)