GF4J 0.9.4 Beta

gameframe.engines.jdk11x
Class CComponentGraphicsEngine.CClippedBitmap

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

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

Implementation of the bitmap image for plain Java 1.1 graphics engine. This bitmap represents a bitmap that uses partial data of some other bitmap and thus has to use clip regions when it is blitted to screen.


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.
(package private)  java.awt.Image m_image
          Reference to the AWT image that represents the bitmap in this graphics engine.
(package private)  int m_xOffset
          The X-offset that is added when drawing this bitmap.
(package private)  int m_yOffset
          The Y-offset that is added when drawing this bitmap.
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
(package private) CComponentGraphicsEngine.CClippedBitmap(CComponentGraphicsEngine.CBitmap original, int srcX, int srcY, int imageWidth, int imageHeight)
          Constructs a bitmap control object from the given bitmap.
(package private) CComponentGraphicsEngine.CClippedBitmap(CComponentGraphicsEngine.CClippedBitmap original, int srcX, int srcY, int imageWidth, int imageHeight)
          Constructs a bitmap control object from the given bitmap.
 
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 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.

m_xOffset

int m_xOffset
The X-offset that is added when drawing this bitmap.

m_yOffset

int m_yOffset
The Y-offset that is added when drawing this bitmap.
Constructor Detail

CComponentGraphicsEngine.CClippedBitmap

CComponentGraphicsEngine.CClippedBitmap(CComponentGraphicsEngine.CBitmap original,
                                        int srcX,
                                        int srcY,
                                        int imageWidth,
                                        int imageHeight)
Constructs a bitmap control object from the given bitmap. This constructor is used when we want to create only a new control object without duplicating the data.
Parameters:
original - The original bitmap that is used as the data source.
srcX - The source images x-offset.
srcY - The source images y-offset.
imageWidth - The width of this image.
imageHeight - The height of this image.

CComponentGraphicsEngine.CClippedBitmap

CComponentGraphicsEngine.CClippedBitmap(CComponentGraphicsEngine.CClippedBitmap original,
                                        int srcX,
                                        int srcY,
                                        int imageWidth,
                                        int imageHeight)
Constructs a bitmap control object from the given bitmap. This constructor is used when we want to create only a new control object without duplicating the data.
Parameters:
original - The original bitmap that is used as the data source.
srcX - The source images x-offset.
srcY - The source images y-offset.
imageWidth - The width of this image.
imageHeight - The height of this image.
Method Detail

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