org.jSyncManager.API.Tools.PalmDataTypes.Bitmaps

Class Bitmap


public class Bitmap
extends java.lang.Object

An image in Palm TBMP format. A Bitmap holds the raw TBMP data and exposes meta information such as width, height, bits per pixel, and compression type.

Field Summary

static int
FLAG_COMPRESSED
static int
FLAG_DIRECT_COLOR
static int
FLAG_HAS_COLOR_TABLE
static int
FLAG_TRANSPARENCY
static int
PACKBITS_COMPRESSION
static int
RLE_COMPRESSION
static int
SCANLINE_COMPRESSION

Constructor Summary

Bitmap(File file)
Constructs a Bitmap from a File.
Bitmap(InputStream in)
Constructs a Bitmap from an InputStream.
Bitmap(byte[] data)
Constructs a TBMP from a byte array.

Method Summary

int
getBitDepth()
int
getBytesPerRow()
int
getCompressionType()
int
getHeight()
int
getSize()
int
getTransparencyIndex()
int
getUncompressedSize()
int
getVersion()
int
getWidth()
boolean
hasColorTable()
boolean
isCompressed()
boolean
isDirectColor()
boolean
isTransparent()
byte[]
toByteArray()

Field Details

FLAG_COMPRESSED

public static final int FLAG_COMPRESSED
Field Value:
32768

FLAG_DIRECT_COLOR

public static final int FLAG_DIRECT_COLOR
Field Value:
1024

FLAG_HAS_COLOR_TABLE

public static final int FLAG_HAS_COLOR_TABLE
Field Value:
16384

FLAG_TRANSPARENCY

public static final int FLAG_TRANSPARENCY
Field Value:
8192

PACKBITS_COMPRESSION

public static final int PACKBITS_COMPRESSION
Field Value:
2

RLE_COMPRESSION

public static final int RLE_COMPRESSION
Field Value:
1

SCANLINE_COMPRESSION

public static final int SCANLINE_COMPRESSION
Field Value:
0

Constructor Details

Bitmap

public Bitmap(File file)
            throws IOException
Constructs a Bitmap from a File.
Parameters:
file - The File to read the TBMP data from.

Bitmap

public Bitmap(InputStream in)
            throws IOException
Constructs a Bitmap from an InputStream. Note that the InputStream is read completely.
Parameters:
in - The InputStream to read the TBMP data from.

Bitmap

public Bitmap(byte[] data)
Constructs a TBMP from a byte array.
Parameters:
data - The raw TBMP data.

Method Details

getBitDepth

public int getBitDepth()
Returns:
The bits per pixel.

1, 2, 4 bpp: 2, 4, 16 shades of gray respectively
8, 16 bpp: 256, 65536 colors respectively


getBytesPerRow

public int getBytesPerRow()
Returns:
The number of bytes per row. The number of bytes per row is the (bitDepth/8) * width, rounded above to an even number. (The padding byte contains no image data.)

getCompressionType

public int getCompressionType()
Returns:
The type of compression used in the bitmap.

0 = scanline
1 = RLE
2 = packbits


getHeight

public int getHeight()
Returns:
The height in pixels of this bitmap.

getSize

public int getSize()
Returns:
The size in bytes of this Bitmap.

getTransparencyIndex

public int getTransparencyIndex()
Returns:
The index of the transparent color in this bitmap.

getUncompressedSize

public int getUncompressedSize()

getVersion

public int getVersion()
Returns:
The version number of the bitmap.

0 = Palm OS 1
1 = Palm OS 3 ( adds scanline compression)
2 = Palm OS 3.5 (adds RLE compression and transparency)
3 = Palm OS 4 (adds packbits compression)


getWidth

public int getWidth()
Returns:
The width in pixels of this bitmap.

hasColorTable

public boolean hasColorTable()
Returns:
A boolean indicating if the bitmap has a color lookup table. A color lookup table is used only in 8-bit bitmap.

isCompressed

public boolean isCompressed()
Returns:
A boolean indicating if the bitmap is compressed through scanline, run-length, or packbits encoding.

isDirectColor

public boolean isDirectColor()
Returns:
A boolean indicating if the bitmap uses a direct color model. A direct color model is used only in 16-bit bitmaps.

isTransparent

public boolean isTransparent()
Returns:
A boolean indicating if the bitmap has a transparent color.

toByteArray

public byte[] toByteArray()
Returns:
A byte array containing the raw TBMP data.