GF4J 0.9.4 Beta

gameframe.engines.msjava4x
Class CDDAlphaBitmap

java.lang.Object
  |
  +--gameframe.engines.msjava4x.CBitmapBase
        |
        +--gameframe.engines.msjava4x.CDDAlphaBitmap
All Implemented Interfaces:
Bitmap, DrawableBitmap

class CDDAlphaBitmap
extends CBitmapBase
implements Bitmap, DrawableBitmap

Implementation of the transparent bitmap image for the Microsoft Java DirectX platform.

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

Field Summary
private  byte m_alphaKeyBlue
          blue alpha key component.
private  byte m_alphaKeyGreen
          Green alpha key component.
private  byte m_alphaKeyRed
          Red alpha key component.
 
Fields inherited from class gameframe.engines.msjava4x.CBitmapBase
m_backBufferHeight, m_backBufferWidth, m_bitmapStorage, m_dd, m_ddBackBuffer, m_ddSurface, m_fInVideoMem, m_height, m_srcRectangle, m_srcRectFromOriginBitmap, m_strOriginBitmapFilename, m_superBitmap, m_width, mStatic_dstRectangle, mStatic_tempFiles
 
Constructor Summary
(package private) CDDAlphaBitmap(gameframe.engines.msjava4x.DirectDraw dd, gameframe.engines.msjava4x.DirectDrawSurface ddBackBuffer, gameframe.engines.msjava4x.DirectDrawSurface ddSurface, int width, int height, IBitmapStorage bitmapStorage, java.lang.String strOriginFile, byte alphaKeyRed, byte alphaKeyGreen, byte alphaKeyBlue)
          Constructs a bitmap from the given paramters.
(package private) CDDAlphaBitmap(gameframe.engines.msjava4x.DirectDraw dd, gameframe.engines.msjava4x.DirectDrawSurface ddBackBuffer, gameframe.engines.msjava4x.DirectDrawSurface ddSurface, int width, int height, IBitmapStorage bitmapStorage, java.lang.String strOriginFile, gameframe.engines.msjava4x.Rect originRect, byte alphaKeyRed, byte alphaKeyGreen, byte alphaKeyBlue)
          Constructs a bitmap from the given paramters.
 
Method Summary
 void blitTo(DrawableBitmap bitmap, int x, int y)
          Draws the bitmap to the given drawable bitmap at the given location.
 void blitTo(int x, int y)
          Draws the bitmap to the graphics engine that loaded it at the given location.
 void finalize()
          Releases all resources held by this bitmap representation.
 Bitmap getClone(BitmapEffect effect)
          Returns an effect processed clone of this bitmap.
 int getHeight()
          Returns the height of the bitmap.
 Bitmap getSubBitmap(int srcX, int srcY, int srcWidth, int srcHeight)
          Returns a bitmap that represents a part of this bitmap by using a new control object, but using the old bitmap data (saves memory, but is resulting bitmap is not that fast to blit on many platforms, on the platforms where this method is really too slow for interactive use the implementation might actually copy the data as with the getSubBitmapClose() method to speed things up to interactive level).
 Bitmap getSubBitmapClone(int srcX, int srcY, int srcWidth, int srcHeight)
          Returns a bitmap that represents a part of this bitmap.
 int getWidth()
          Returns the width of the bitmap.
 void strecthTo(DrawableBitmap bitmap, int x, int y, int width, int height)
          Draws the bitmap to the given drawable bitmap at the given location at the given size.
 void strecthTo(int x, int y, int width, int height)
          Draws the bitmap to the graphics engine that loaded it at the given location and at the given size.
 
Methods inherited from class gameframe.engines.msjava4x.CBitmapBase
getData, getEffectSurface, getSurfaceFromData, restore, setDataToSurface
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_alphaKeyRed

private byte m_alphaKeyRed
Red alpha key component.

m_alphaKeyGreen

private byte m_alphaKeyGreen
Green alpha key component.

m_alphaKeyBlue

private byte m_alphaKeyBlue
blue alpha key component.
Constructor Detail

CDDAlphaBitmap

CDDAlphaBitmap(gameframe.engines.msjava4x.DirectDraw dd,
               gameframe.engines.msjava4x.DirectDrawSurface ddBackBuffer,
               gameframe.engines.msjava4x.DirectDrawSurface ddSurface,
               int width,
               int height,
               IBitmapStorage bitmapStorage,
               java.lang.String strOriginFile,
               byte alphaKeyRed,
               byte alphaKeyGreen,
               byte alphaKeyBlue)
Constructs a bitmap from the given paramters.
Parameters:
dd - The DirectDraw object that can create new DD surfaces.
ddSurface - The DirectDraw surface this bitmap class represents.
width - Width of the DirectDraw surface this bitmap class represents.
height - Height of the DirectDraw surface this bitmap class represents.
bitmapStorage - The storage that stores all bitmaps created by this bitmap.
strOriginFile - The originating bitmap file.

CDDAlphaBitmap

CDDAlphaBitmap(gameframe.engines.msjava4x.DirectDraw dd,
               gameframe.engines.msjava4x.DirectDrawSurface ddBackBuffer,
               gameframe.engines.msjava4x.DirectDrawSurface ddSurface,
               int width,
               int height,
               IBitmapStorage bitmapStorage,
               java.lang.String strOriginFile,
               gameframe.engines.msjava4x.Rect originRect,
               byte alphaKeyRed,
               byte alphaKeyGreen,
               byte alphaKeyBlue)
Constructs a bitmap from the given paramters.
Parameters:
dd - The DirectDraw object that can create new DD surfaces.
ddSurface - The DirectDraw surface this bitmap class represents.
width - Width of the DirectDraw surface this bitmap class represents.
height - Height of the DirectDraw surface this bitmap class represents.
bitmapStorage - The storage that stores all bitmaps created by this bitmap.
strOriginFile - The originating bitmap file.
originRect - The originating bitmaps rectangle that is this bitmap.
Method Detail

finalize

public void finalize()
Releases all resources held by this bitmap representation.
Specified by:
finalize in interface Bitmap
Overrides:
finalize in class CBitmapBase

blitTo

public void blitTo(int x,
                   int y)
Draws the bitmap to the graphics engine that loaded it at the given location. The location can be outside of the visible screen area in which case the bitmap is clipped accordingly.
Specified by:
blitTo in interface Bitmap
Parameters:
x - The x-coordinate of the location where the image is drawn to.
y - The y-coordinate of the location where the image is drawn to.

strecthTo

public void strecthTo(int x,
                      int y,
                      int width,
                      int height)
Draws the bitmap to the graphics engine that loaded it at the given location and at the given size. If this bitmap is larger or smaller than the destination size the bitmap will automatically be scaled. Note: This method is slow, so it's use is not preferred during actual game play.
Specified by:
strecthTo in interface Bitmap
Parameters:
x - The x-coordinate of the location where the image is drawn to.
y - The y-coordinate of the location where the image is drawn to.
width - The with of the destination where the image is drawn to.
height - The height of the destination where the image is drawn to.

getClone

public Bitmap getClone(BitmapEffect effect)
                throws GameFrameException
Returns an effect processed clone of this bitmap.
Specified by:
getClone in interface Bitmap
Parameters:
effect - The effect to be applied to the clone bitmap, or null if none are to be applied.
Returns:
An effect processed clone of this bitmap.
Throws:
GameFrameException - thrown if any errors occur.

getSubBitmapClone

public Bitmap getSubBitmapClone(int srcX,
                                int srcY,
                                int srcWidth,
                                int srcHeight)
                         throws GameFrameException
Returns a bitmap that represents a part of this bitmap. Useful for e.g. extracting animation frames from one bitmap. If for any reason the creation of the new bitmap fails (out of memory etc.) this method returns null. If the given rectangle is outside of the bitmap area of the original bitmap or even larger than the original bitmap area this method functions in an unpredictable manner (e.g. returns null or return junk).
Specified by:
getSubBitmapClone in interface Bitmap
Parameters:
srcX - The area of the bitmap to be returned as a new bitmap.
srcY - The area of the bitmap to be returned as a new bitmap.
srcWidth - The area of the bitmap to be returned as a new bitmap.
srcHeight - The area of the bitmap to be returned as a new bitmap.
Returns:
A new bitmap representing the requested part of the original bitmap.

getSubBitmap

public Bitmap getSubBitmap(int srcX,
                           int srcY,
                           int srcWidth,
                           int srcHeight)
                    throws GameFrameException
Returns a bitmap that represents a part of this bitmap by using a new control object, but using the old bitmap data (saves memory, but is resulting bitmap is not that fast to blit on many platforms, on the platforms where this method is really too slow for interactive use the implementation might actually copy the data as with the getSubBitmapClose() method to speed things up to interactive level). Useful for e.g. extracting animation frames from one bitmap. This method is not very fast and should be preferrably called during game initialization. If for any reason the creation of the new bitmap fails (out of memory etc.) this method returns null. If the given rectangle is outside of the bitmap area of the original bitmap or even larger than the original bitmap area this method functions in an unpredictable manner (e.g. returns null or junk).
Specified by:
getSubBitmap in interface Bitmap
Parameters:
srcX - The area of the bitmap to be returned as a new bitmap.
srcY - The area of the bitmap to be returned as a new bitmap.
srcWidth - The area of the bitmap to be returned as a new bitmap.
srcHeight - The area of the bitmap to be returned as a new bitmap.
Returns:
A new bitmap representing the requested part of the original bitmap.

getWidth

public int getWidth()
Returns the width of the bitmap.
Specified by:
getWidth in interface Bitmap
Returns:
Width of the bitmap if available.

getHeight

public int getHeight()
Returns the height of the bitmap.
Specified by:
getHeight in interface Bitmap
Returns:
Height of the bitmap if available.

blitTo

public void blitTo(DrawableBitmap bitmap,
                   int x,
                   int y)
Draws the bitmap to the given drawable bitmap at the given location. The location can be outside of the visible screen area in which case the bitmap is clipped accordingly. This method is fast and is usable during the game execution.
Specified by:
blitTo in interface Bitmap
Parameters:
bitmap - The bitmap that will be drawn to this bitmap.
x - The x-coordinate of the location where the image is drawn to.
y - The y-coordinate of the location where the image is drawn to.

strecthTo

public void strecthTo(DrawableBitmap bitmap,
                      int x,
                      int y,
                      int width,
                      int height)
Draws the bitmap to the given drawable bitmap at the given location at the given size. If this bitmap is larger or smaller than the destination size the bitmap will automatically be scaled. Note: This method is slow, so it's use is not preferred during actual game play.
Specified by:
strecthTo in interface Bitmap
Parameters:
bitmap - The bitmap that will be drawn to this bitmap.
x - The x-coordinate of the location where the image is drawn to.
y - The y-coordinate of the location where the image is drawn to.
width - The with of the destination where the image is drawn to.
height - The height of the destination where the image is drawn to.

GF4J 0.9.4 Beta