GF4J 0.9.4 Beta

gameframe.graphics
Class BitmapData

java.lang.Object
  |
  +--gameframe.graphics.BitmapData
All Implemented Interfaces:
java.lang.Cloneable

public class BitmapData
extends java.lang.Object
implements java.lang.Cloneable

Represents the bitmap data loaded from a bitmap file.

Since:
GameFrame for Java 0.9.3
Version:
GameFrame for Java 0.9.4

Field Summary
protected  int[] m_aPalette
          The palette of the bitmap (if paletted color bitmap) or null if no palette available.
protected  int[] m_aPixels
          The pixel data array.
protected  int m_height
          The bitmap height.
protected  int m_keyColorBlue
          The bitmap keycolor blue value.
protected  int m_keyColorGreen
          The bitmap keycolor green value.
protected  int m_keyColorRed
          The bitmap keycolor red value.
protected  int m_numBlueBits
          The number of bits used to represent the blue component in a pixel.
protected  int m_numGreenBits
          The number of bits used to represent the green component in a pixel.
protected  int m_numRedBits
          The number of bits used to represent the red component in a pixel.
protected  int m_pitch
          The number of pixels you need to travel to step one pixel down.
protected  int m_width
          The bitmap width.
static int NOT_USED
          The value of any key color component if it is not used.
 
Constructor Summary
BitmapData(int[] aPixels, int width, int height, int pitch)
          Constructs a bitmap data object that has the given parameters.
BitmapData(int[] aPixels, int width, int height, int pitch, int[] aPalette)
          Constructs a bitmap data object that has the given parameters.
BitmapData(int[] aPixels, int width, int height, int pitch, int keyColorRed, int keyColorGreen, int keyColorBlue)
          Constructs a bitmap data object that has the given parameters.
BitmapData(int[] aPixels, int width, int height, int pitch, int keyColorRed, int keyColorGreen, int keyColorBlue, int[] aPalette)
          Constructs a bitmap data object that has the given parameters.
 
Method Summary
 BitmapData getCopy()
          Returns a copy of the bitmap data.
 int getHeight()
          Returns the height of the bitmap.
 int getKeyColorBlue()
          Returns the red component of the keycolor.
 int getKeyColorGreen()
          Returns the red component of the keycolor.
 int getKeyColorRed()
          Returns the red component of the keycolor.
 int getNumBlueBits()
          Returns the number of bits used for the red component in a pixel.
 int getNumGreenBits()
          Returns the number of bits used for the red component in a pixel.
 int getNumRedBits()
          Returns the number of bits used for the red component in a pixel.
 int[] getPalette()
          Returns the palette array in the default color format.
 int getPitch()
          Returns the number of pixels that needs to be travelled in the pixel array in order to step one pixel down in the bitmap.
 int[] getPixels()
          Returns the pixel data array in the default color format.
private  BitmapData getRectData(int srcX, int srcY, int srcWidth, int srcHeight)
          Returns the given rectangle of the bitmap data.
 int getWidth()
          Returns the width of the bitmap.
 boolean isKeyColourInUse()
          Returns whether this bitmap data uses the keycolor or not.
 boolean isPaletted()
          Returns whether this image data uses a palette or not.
 void setColourBits(int numRedBits, int numGreenBits, int numBlueBits)
          Sets the colour bits (the number of bits used for each colour).
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

NOT_USED

public static final int NOT_USED
The value of any key color component if it is not used.

m_aPixels

protected int[] m_aPixels
The pixel data array.

m_width

protected int m_width
The bitmap width.

m_height

protected int m_height
The bitmap height.

m_pitch

protected int m_pitch
The number of pixels you need to travel to step one pixel down.

m_numRedBits

protected int m_numRedBits
The number of bits used to represent the red component in a pixel.

m_numGreenBits

protected int m_numGreenBits
The number of bits used to represent the green component in a pixel.

m_numBlueBits

protected int m_numBlueBits
The number of bits used to represent the blue component in a pixel.

m_keyColorRed

protected int m_keyColorRed
The bitmap keycolor red value. This field is valid only if the bitmap was loaded as alpha bitmap.

m_keyColorGreen

protected int m_keyColorGreen
The bitmap keycolor green value. This field is valid only if the bitmap was loaded as alpha bitmap.

m_keyColorBlue

protected int m_keyColorBlue
The bitmap keycolor blue value. This field is valid only if the bitmap was loaded as alpha bitmap.

m_aPalette

protected int[] m_aPalette
The palette of the bitmap (if paletted color bitmap) or null if no palette available.
Constructor Detail

BitmapData

public BitmapData(int[] aPixels,
                  int width,
                  int height,
                  int pitch)
Constructs a bitmap data object that has the given parameters.
Parameters:
aPixels - The pixels in default colour format.
width - The width of the bitmap.
height - The height of the bitmap.
pitch - The number of pixels to step one pixel downwards.

BitmapData

public BitmapData(int[] aPixels,
                  int width,
                  int height,
                  int pitch,
                  int keyColorRed,
                  int keyColorGreen,
                  int keyColorBlue)
Constructs a bitmap data object that has the given parameters.
Parameters:
aPixels - The pixels in default colour format.
width - The width of the bitmap.
height - The height of the bitmap.
pitch - The number of pixels to step one pixel downwards.
keyColorRed - The alpha key colours red component value.
keyColorGreen - The alpha key colours green component value.
keyColorBlue - The alpha key colours blue component value.
aPalette - The palette array (in default RGB format).

BitmapData

public BitmapData(int[] aPixels,
                  int width,
                  int height,
                  int pitch,
                  int[] aPalette)
Constructs a bitmap data object that has the given parameters.
Parameters:
aPixels - The pixels in default colour format.
width - The width of the bitmap.
height - The height of the bitmap.
pitch - The number of pixels to step one pixel downwards.
aPalette - The palette array (in default RGB format).

BitmapData

public BitmapData(int[] aPixels,
                  int width,
                  int height,
                  int pitch,
                  int keyColorRed,
                  int keyColorGreen,
                  int keyColorBlue,
                  int[] aPalette)
Constructs a bitmap data object that has the given parameters.
Parameters:
aPixels - The pixels in default colour format.
width - The width of the bitmap.
height - The height of the bitmap.
pitch - The number of pixels to step one pixel downwards.
keyColorRed - The alpha key colours red component value.
keyColorGreen - The alpha key colours green component value.
keyColorBlue - The alpha key colours blue component value.
aPalette - The palette array (in default RGB format).
Method Detail

getPixels

public int[] getPixels()
Returns the pixel data array in the default color format.
Returns:
Pixel data array

getNumRedBits

public int getNumRedBits()
Returns the number of bits used for the red component in a pixel.
Returns:
The number of bits for red colour.

getNumGreenBits

public int getNumGreenBits()
Returns the number of bits used for the red component in a pixel.
Returns:
The number of bits for red colour.

getNumBlueBits

public int getNumBlueBits()
Returns the number of bits used for the red component in a pixel.
Returns:
The number of bits for red colour.

setColourBits

public void setColourBits(int numRedBits,
                          int numGreenBits,
                          int numBlueBits)
Sets the colour bits (the number of bits used for each colour).
Parameters:
numRedBits - The number of bits used for the red colour.
numGreenBits - The number of bits used for the green colour.
numBlueBits - The number of bits used for the blue colour.

isPaletted

public final boolean isPaletted()
Returns whether this image data uses a palette or not.
Returns:
True if the image is paletted, false if not.

getPalette

public int[] getPalette()
Returns the palette array in the default color format.
Returns:
Palette array.

getWidth

public int getWidth()
Returns the width of the bitmap.
Returns:
Width of the bitmap

getPitch

public int getPitch()
Returns the number of pixels that needs to be travelled in the pixel array in order to step one pixel down in the bitmap.
Returns:
The pitch of the bitmap.

getHeight

public int getHeight()
Returns the height of the bitmap.
Returns:
Height of the bitmap

getKeyColorRed

public int getKeyColorRed()
Returns the red component of the keycolor. Valid only if bitmap was loaded as alphabitmap.
Returns:
Red component of the keycolor.

getKeyColorGreen

public int getKeyColorGreen()
Returns the red component of the keycolor. Valid only if bitmap was loaded as alphabitmap.
Returns:
Red component of the keycolor.

getKeyColorBlue

public int getKeyColorBlue()
Returns the red component of the keycolor. Valid only if bitmap was loaded as alphabitmap.
Returns:
Red component of the keycolor.

isKeyColourInUse

public boolean isKeyColourInUse()
Returns whether this bitmap data uses the keycolor or not.
Returns:
True if keycolour is defined or false if not.

getCopy

public BitmapData getCopy()
Returns a copy of the bitmap data.
Returns:
A copy of the bitmap data.

getRectData

private BitmapData getRectData(int srcX,
                               int srcY,
                               int srcWidth,
                               int srcHeight)
Returns the given rectangle of the bitmap data.
Returns:
The given rectangles bitmap data.

GF4J 0.9.4 Beta