GF4J 0.9.4 Beta

gameframe.graphics
Class BitmapFile

java.lang.Object
  |
  +--gameframe.graphics.BitmapFile

public class BitmapFile
extends java.lang.Object

Represents Windows Bitmap (BMP) file and has utility methods for loading a Windows Bitmap file and returning its bitmap data.

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

Field Summary
private static int[] mStatic_aBitmask
          Bitmask array used to read the monochrome bitmaps
private static int RGB_ONLY_MASK
          Bitmask that can be used to handle only the RGB part of the colours.
 
Constructor Summary
BitmapFile()
           
 
Method Summary
private static void fillBuffer(java.io.InputStream inStream, byte[] aBuffer)
          Fills (to full capacity) the given buffer from the given input stream.
 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.
static BitmapData loadBMP(java.io.InputStream inStream, java.lang.String strFileName, boolean fEnableAlpha)
          Handles the loading of the bitmap from the given input stream.
static BitmapData loadBMP(java.io.InputStream inStream, java.lang.String strFileName, byte alphakeyRed, byte alphakeyGreen, byte alphakeyBlue)
          Handles the loading of the bitmap from the given input stream.
static BitmapData loadBMP(java.lang.String strFileName, boolean fEnableAlpha)
          Loads the given file containing a Windows BMP formatted bitmap and returns an object containing the raw pixel data and the dimensions of the loaded bitmap.
static BitmapData loadBMP(java.lang.String strFileName, byte red, byte green, byte blue)
          Loads the given file containing a Windows BMP formatted bitmap and returns an object containing the raw pixel data and the dimensions of the loaded bitmap.
static BitmapData loadBMPURL(java.lang.String strFileName, boolean fEnableAlpha)
          Loads the file at the given URL containing a Windows BMP formatted bitmap and returns an object containing the raw pixel data and the dimensions of the loaded bitmap.
static BitmapData loadBMPURL(java.lang.String strFileName, byte red, byte green, byte blue)
          Loads the file at the given URL containing a Windows BMP formatted bitmap and returns an object containing the raw pixel data and the dimensions of the loaded bitmap.
private static byte mapFromPixelToPalette(int pixel, int[] aPalette)
          Maps the pixel value to the value in the palette
private static void save24Bit(java.io.OutputStream outStream, BitmapData bitmapData)
          Saves the bitmap to the outputstream in 8-bit BMP format.
private static void save8Bit(java.io.OutputStream outStream, BitmapData bitmapData)
          Saves the bitmap and palette data to the outputstream in 8-bit BMP format.
static void saveBMP(java.lang.String strFileName, BitmapData bitmapData)
          Saves the given bitmap to a Windows BMP formatted file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

mStatic_aBitmask

private static final int[] mStatic_aBitmask
Bitmask array used to read the monochrome bitmaps

RGB_ONLY_MASK

private static final int RGB_ONLY_MASK
Bitmask that can be used to handle only the RGB part of the colours.
Constructor Detail

BitmapFile

public BitmapFile()
Method Detail

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.

saveBMP

public static void saveBMP(java.lang.String strFileName,
                           BitmapData bitmapData)
                    throws GameFrameException
Saves the given bitmap to a Windows BMP formatted file.
Parameters:
strFileName - The name of the file to save to.
bitmapData - The bitmap data (width, height and raw pixel data).

save8Bit

private static final void save8Bit(java.io.OutputStream outStream,
                                   BitmapData bitmapData)
                            throws java.io.IOException
Saves the bitmap and palette data to the outputstream in 8-bit BMP format.
Parameters:
outStream - The stream to write to.
bitmapData - The bitmap data to be written.

save24Bit

private static final void save24Bit(java.io.OutputStream outStream,
                                    BitmapData bitmapData)
                             throws java.io.IOException
Saves the bitmap to the outputstream in 8-bit BMP format.
Parameters:
outStream - The stream to write to.
bitmapData - The bitmap data to be written.

mapFromPixelToPalette

private static final byte mapFromPixelToPalette(int pixel,
                                                int[] aPalette)
Maps the pixel value to the value in the palette

loadBMPURL

public static final BitmapData loadBMPURL(java.lang.String strFileName,
                                          boolean fEnableAlpha)
                                   throws java.io.FileNotFoundException,
                                          GameFrameException
Loads the file at the given URL containing a Windows BMP formatted bitmap and returns an object containing the raw pixel data and the dimensions of the loaded bitmap.
Parameters:
strFileName - The name of the file to load.
fEnableAlpha - True if bitmap is to be loaded as alpha bitmap.
Returns:
The bitmap data (width, height and raw pixel data).

loadBMPURL

public static final BitmapData loadBMPURL(java.lang.String strFileName,
                                          byte red,
                                          byte green,
                                          byte blue)
                                   throws java.io.FileNotFoundException,
                                          GameFrameException
Loads the file at the given URL containing a Windows BMP formatted bitmap and returns an object containing the raw pixel data and the dimensions of the loaded bitmap.
Parameters:
strFileName - The name of the file to load.
red - The red key color intensity value (in range 0x00-0xFF).
green - The green key color intensity value (in range 0x00-0xFF).
blue - The blue key color intensity value (in range 0x00-0xFF).
Returns:
The bitmap data (width, height and raw pixel data).

loadBMP

public static final BitmapData loadBMP(java.lang.String strFileName,
                                       boolean fEnableAlpha)
                                throws java.io.FileNotFoundException,
                                       GameFrameException
Loads the given file containing a Windows BMP formatted bitmap and returns an object containing the raw pixel data and the dimensions of the loaded bitmap.
Parameters:
strFileName - The name of the file to load.
fEnableAlpha - True if bitmap is to be loaded as alpha bitmap.
Returns:
The bitmap data (width, height and raw pixel data).

loadBMP

public static final BitmapData loadBMP(java.lang.String strFileName,
                                       byte red,
                                       byte green,
                                       byte blue)
                                throws java.io.FileNotFoundException,
                                       GameFrameException
Loads the given file containing a Windows BMP formatted bitmap and returns an object containing the raw pixel data and the dimensions of the loaded bitmap.
Parameters:
strFileName - The name of the file to load.
red - The red key color intensity value (in range 0x00-0xFF).
green - The green key color intensity value (in range 0x00-0xFF).
blue - The blue key color intensity value (in range 0x00-0xFF).
Returns:
The bitmap data (width, height and raw pixel data).

loadBMP

public static final BitmapData loadBMP(java.io.InputStream inStream,
                                       java.lang.String strFileName,
                                       boolean fEnableAlpha)
                                throws java.io.FileNotFoundException,
                                       GameFrameException
Handles the loading of the bitmap from the given input stream.
Parameters:
inStream - The input stream to load from.
strFileName - The filename used in error texts.
fEnableAlpha - Flag indicating if key color should be used or not.

loadBMP

public static final BitmapData loadBMP(java.io.InputStream inStream,
                                       java.lang.String strFileName,
                                       byte alphakeyRed,
                                       byte alphakeyGreen,
                                       byte alphakeyBlue)
                                throws java.io.FileNotFoundException,
                                       GameFrameException
Handles the loading of the bitmap from the given input stream.
Parameters:
inStream - The input stream to load from.
strFileName - The filename used in error texts.
alphakeyRed - The red alpha key value (in range 0x00-0xFF).
alphakeyGreen - The green alpha key value (in range 0x00-0xFF).
alphakeyBlue - The blue alpha key value (in range 0x00-0xFF).

fillBuffer

private static final void fillBuffer(java.io.InputStream inStream,
                                     byte[] aBuffer)
                              throws java.io.IOException
Fills (to full capacity) the given buffer from the given input stream.
Parameters:
inStream - The input sream to read the data from.
aBuffer - The buffer that is filled with the read data.

GF4J 0.9.4 Beta