GF4J 0.9.4 Beta

gameframe.engines.msjava4x
Class CPixelConverter

java.lang.Object
  |
  +--gameframe.engines.msjava4x.CPixelConverter

class CPixelConverter
extends java.lang.Object

Implementation of an pixel converter that converts arrays containing bitmap data from one pixel format to another.

Since:
GameFrame for Java 0.9
Version:
GameFrame for Java 0.9.4

Field Summary
private  int m_alphaMask
          The alpha mask.
private  int m_alphaMaskBeginIdx
          The alpha mask beginning index.
private  int m_blueMask
          The blue mask.
private  int m_blueMaskBeginIdx
          The blue mask beginning index.
private  int m_greenMask
          The green mask.
private  int m_greenMaskBeginIdx
          The green mask beginning index.
private  int m_numAlphaMaskBits
          The alpha mask bit count.
private  int m_numBlueMaskBits
          The blue mask bit count.
private  int m_numGreenMaskBits
          The green mask bit count.
private  int m_numRedMaskBits
          The red mask bit count.
private  int m_redMask
          The red mask.
private  int m_redMaskBeginIdx
          The red mask beginning index.
 
Constructor Summary
CPixelConverter(com.ms.directX.DDPixelFormat pixelFormat)
          Constructs a pixel converter that converts between the given format and the Java native 0xAARRGGBB format.
CPixelConverter(int alphaMask, int redMask, int greenMask, int blueMask)
          Constructs a pixel converter that converts between the given format and the Java native 0xAARRGGBB format.
 
Method Summary
 void convertFromJavaNative(int[] aiPixels)
          Converts pixels in Java native format to the pixel format given in the constructor.
 void convertToJavaNative(int[] aiPixels)
          Converts pixels in the pixel format given in the constructor to Java native format.
(package private) static int getIntensity(int pixelValue, int mask)
          Maps the given pixel value with the given mask to an 8-bit color intensity value.
private  int getMaskBeginIdx(int mask)
          Calculates the beginning index of the given mask.
private  int getMaskBits(int mask)
          Calculates the number of bits in the given mask.
 int getNumBlueBits()
          Returns the number of bits used to represent the blue component.
 int getNumGreenBits()
          Returns the number of bits used to represent the green component.
 int getNumRedBits()
          Returns the number of bits used to represent the red component.
(package private) static int getPixelValue(int colorIntensity, int mask)
          Maps the given value (0x00-0xFF) to the given mask.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_alphaMask

private int m_alphaMask
The alpha mask.

m_redMask

private int m_redMask
The red mask.

m_greenMask

private int m_greenMask
The green mask.

m_blueMask

private int m_blueMask
The blue mask.

m_alphaMaskBeginIdx

private int m_alphaMaskBeginIdx
The alpha mask beginning index.

m_redMaskBeginIdx

private int m_redMaskBeginIdx
The red mask beginning index.

m_greenMaskBeginIdx

private int m_greenMaskBeginIdx
The green mask beginning index.

m_blueMaskBeginIdx

private int m_blueMaskBeginIdx
The blue mask beginning index.

m_numAlphaMaskBits

private int m_numAlphaMaskBits
The alpha mask bit count.

m_numRedMaskBits

private int m_numRedMaskBits
The red mask bit count.

m_numGreenMaskBits

private int m_numGreenMaskBits
The green mask bit count.

m_numBlueMaskBits

private int m_numBlueMaskBits
The blue mask bit count.
Constructor Detail

CPixelConverter

public CPixelConverter(com.ms.directX.DDPixelFormat pixelFormat)
Constructs a pixel converter that converts between the given format and the Java native 0xAARRGGBB format.
Parameters:
pixelFormat - The DirectDraw pixel format.

CPixelConverter

public CPixelConverter(int alphaMask,
                       int redMask,
                       int greenMask,
                       int blueMask)
Constructs a pixel converter that converts between the given format and the Java native 0xAARRGGBB format.
Parameters:
alphaMask - The alpha value mask.
redMask - The red value mask.
greenMask - The green value mask.
blueMask - The blue value mask.
Method Detail

getNumRedBits

public int getNumRedBits()
Returns the number of bits used to represent the red component.
Returns:
Bits used for the red.

getNumGreenBits

public int getNumGreenBits()
Returns the number of bits used to represent the green component.
Returns:
Bits used for the green.

getNumBlueBits

public int getNumBlueBits()
Returns the number of bits used to represent the blue component.
Returns:
Bits used for the blue.

convertToJavaNative

public void convertToJavaNative(int[] aiPixels)
Converts pixels in the pixel format given in the constructor to Java native format.
Parameters:
aiPixels - The pixels in original format, changed to Java native.

convertFromJavaNative

public void convertFromJavaNative(int[] aiPixels)
Converts pixels in Java native format to the pixel format given in the constructor.
Parameters:
aiPixels - The pixels in Java native, changed to original format.

getMaskBeginIdx

private final int getMaskBeginIdx(int mask)
Calculates the beginning index of the given mask.
Parameters:
mask - The bitmask whose beginning is calculated.
Returns:
The beginning index of the given mask.

getMaskBits

private final int getMaskBits(int mask)
Calculates the number of bits in the given mask.
Parameters:
mask - The bitmask whose bits are counted.
Returns:
The number of bits in the mask.

getPixelValue

static final int getPixelValue(int colorIntensity,
                               int mask)
Maps the given value (0x00-0xFF) to the given mask.
Parameters:
colorIntensity - The value of a color intensity.
mask - The mask for the specific color.
Returns:
The byte value mapped to the mask value.

getIntensity

static int getIntensity(int pixelValue,
                        int mask)
Maps the given pixel value with the given mask to an 8-bit color intensity value.
Parameters:
pixelValue - The pixel.
mask - The mask of the color component we want to extract
Returns:
The color intensity.

GF4J 0.9.4 Beta