GF4J 0.9.4 Beta

gameframe.engines.jdk11x
Class CComponentGraphicsEngine.CBitmap

java.lang.Object
  |
  +--gameframe.engines.jdk11x.CComponentGraphicsEngine.CBitmap
All Implemented Interfaces:
Bitmap, java.awt.image.ImageObserver
Enclosing class:
CComponentGraphicsEngine

class CComponentGraphicsEngine.CBitmap
extends java.lang.Object
implements Bitmap, java.awt.image.ImageObserver

Implementation of the bitmap image for plain Java 1.1 graphics engine.


Field Summary
(package private)  int m_bitmapHeight
          Height of the bitmap.
(package private)  int m_bitmapWidth
          Width of the bitmap.
(package private)  java.awt.Rectangle m_clipper
          Clipping region used when drawing the bitmap with clipping.
(package private)  java.awt.Image m_image
          Reference to the AWT image that represents the bitmap in this graphics engine.
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
(package private) CComponentGraphicsEngine.CBitmap(java.awt.Image image)
          Constructs a bitmap control object from the given AWT image.
 
Method Summary
 void blitTo(DrawableBitmap bitmap, int x, int y)
          Draws the given bitmap to this 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 clipTo(DrawableBitmap bitmap, int x, int y, int width, int height)
          Draws the bitmap to the given drawable bitmap at the given location.
 void finalize()
          Frees all the resources that are used by the bitmap implementation.
 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 not that fast on many platforms.
 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.
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
          The image observer method that gets updated when an image is loading.
 void strecthTo(DrawableBitmap bitmap, int x, int y, int width, int height)
          This method traps false usage where the user tries to blit a bitmap that was not loaded by this graphics engine to a bitmap that was created by this graphics engine.
 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 java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_image

java.awt.Image m_image
Reference to the AWT image that represents the bitmap in this graphics engine.

m_bitmapWidth

int m_bitmapWidth
Width of the bitmap.

m_bitmapHeight

int m_bitmapHeight
Height of the bitmap.

m_clipper

java.awt.Rectangle m_clipper
Clipping region used when drawing the bitmap with clipping.
Constructor Detail

CComponentGraphicsEngine.CBitmap

CComponentGraphicsEngine.CBitmap(java.awt.Image image)
Constructs a bitmap control object from the given AWT image.
Parameters:
image - The image that this bitmap represents.
Method Detail

clipTo

public void clipTo(DrawableBitmap bitmap,
                   int x,
                   int y,
                   int width,
                   int height)
Draws the bitmap to the given drawable bitmap at the given location. The drawing is clipped to the rectangle of given width and height. The rectangles upperleft corner is at the given drawing location. No scaling will be done to make the bitmap fit or fill that size.
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 width of the clipping rectangle that starts from the drawing location.
height - The height of the clipping rectangle that starts from the drawing location.

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.

blitTo

public void blitTo(DrawableBitmap bitmap,
                   int x,
                   int y)
Draws the given bitmap to this drawable bitmap 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:
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)
This method traps false usage where the user tries to blit a bitmap that was not loaded by this graphics engine to a bitmap that was created by this graphics engine. This method does nothing.
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.

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.

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. The given dimensions are checked for validity.
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 not that fast on many platforms. On the platforms where this method is too slow for interactive use the implementation might actually copy the data as with the getSubBitmapClone() method to speed things up). Anyhow this method is preferred over getSubBitmapClone() method as in some platforms it can save a lot of memory (e.g. under pure Java 1.1 creation of new bitmaps by cloning the data is VERY memory consuming). Useful for e.g. extracting animation frames from one bitmap. This method isn't usually 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. The given dimensions are checked for validity.
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.

finalize

public void finalize()
Frees all the resources that are used by the bitmap implementation.
Specified by:
finalize in interface Bitmap
Overrides:
finalize in class java.lang.Object

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
The image observer method that gets updated when an image is loading.
Specified by:
imageUpdate in interface java.awt.image.ImageObserver

GF4J 0.9.4 Beta