Bitmap.h
declares the API that this chapter describes. For more information on windows, see the section "Bitmaps" in the Palm OS Programmer's Companion.
BitmapCompressionType
enum specifies possible bitmap compression types. These are the possible values for the compressionType
field of
BitmapType
. You can compress or uncompress a bitmap using a call to
BmpCompress
.
typedef enum {
    BitmapCompressionTypeScanLine = 0,
    BitmapCompressionTypeRLE,
    BitmapCompressionTypeNone = 0xFF
} BitmapCompressionType;
BitmapFlagsType
bit field defines the flags
field of
BitmapType
. It specifies the bitmap's attributes.
typedef struct BitmapFlagsType {
    UInt16 compressed:1;
    UInt16 hasColorTable:1;
    UInt16 hasTransparency:1;
    UInt16 indirect:1;
    UInt16 forScreen:1;
    UInt16 reserved:11;
} BitmapFlagsType;
compressed
and hasColorTable
are only defined if 3.5 New Feature Set is present. Note that the size of this structure did not change.
BitmapPtr
type defines a pointer to a
BitmapType
structure.
typedef BitmapType *BitmapPtr;
BitmapType
structure represents a bitmap. This structure defines both the bitmaps representing the window display and bitmap resources ('Tbmp'
and 'tAIB'
) that you create using Constructor or some other application and load into your program.
typedef struct BitmapType {
    Int16 width;
    Int16 height;
    UInt16 rowBytes;
    BitmapFlagsType flags;
    UInt8 pixelSize;
    UInt8 version;
    UInt16 nextDepthOffset;
    UInt8 transparentIndex;
    UInt8 compressionType;
    UInt16 reserved;
} BitmapType;
width
| The width of the bitmap in pixels. You specify this value when you create the bitmap. |
height
| The height of the bitmap in pixels. You specify this value when you create the bitmap. |
rowBytes
|
The number of bytes stored for each row of the bitmap where height is the number of rows.
|
flags
|
The bitmap's attributes. See BitmapFlagsType .
|
pixelSize
| The pixel depth. Currently supported pixel depths are 1, 2, 4, and 8-bit. You specify this value when you create the bitmap. |
version
| The version of bitmap encoding used. See Bitmap Constants. |
nextDepthOffset
|
For bitmap families, this field specifies the start of the next bitmap in the family. The value it contains is the number of 4-byte words to the next BitmapType from the beginning of this one. If the bitmap is not part of a bitmap family or it is the last bitmap in the family, the nextDepthOffset is 0.
|
transparentIndex
|
The color index for the transparent color. Only used for version 2 bitmaps and only when the transparent flag is set in flags . You specify this value when you create the bitmap using Constructor.
|
compressionType
|
The compression type used. Only used for version 2 bitmaps and only when the compressed flag is set in flags . See BitmapCompressionType for possible values. The BmpCompress function sets this field.
|
reserved
| Reserved for future use. Must be set to 0. |
BitmapType
structure:
BitmapType
header structure. If the bitmap has its own color table, the color table is stored in between the header and the data. You can retrieve a bitmap's data by passing its BitmapType
structure to
BmpGetBits
, and you can retrieve its color table with
BmpGetColortable
.BitmapType
does not store the bitmap's location on the screen. The
WindowType
or the
FormBitmapType
with which this bitmap is associated contains that information. BitmapType
represents a bitmap family, the nextDepthOffset
field contains the offset from the start of this bitmap to the next bitmap in the family. transparentIndex
and compressionType
flags are defined only if 3.5 New Feature Set is present.
ColorTableType
structure defines a color table. Bitmaps can have color tables attached to them; however, doing so is not recommended for performance reasons.
typedef struct ColorTableType {
    UInt16 numEntries;
    // RGBColorType entry[];
} ColorTableType;
RGBColorType
, and there is one per numEntries
. Use the macro
ColorTableEntries
to retrieve these entries.
RGBColorType
structure defines a color. It is used as an entry in the color table. RGBColorTypes
can also be created manually and passed to several user interface functions.
typedef struct RGBColorType {
    UInt8 index;
    UInt8 r;
    UInt8 g;
    UInt8 b;
} RGBColorType;
'Tbmp'
for most images and the resource type 'tAIB'
for application icons. Symbolically, these two resource types are bitmapRsc
an iconType
, respectively.
'tbmf'
resource (or 'taif'
resource for icons) and one or more 'PICT' images, and the PalmRez post linker converts them into a single 'Tbmp'
or 'tAIB'
resource. Note that the PalmRez post linker takes PICT images even on the Microsoft Windows operating system.
UInt16 BmpBitsSize (BitmapType *bitmapP)
indirect
flag is set. (See
BitmapFlagsType
.)
BmpSize
,
BmpColortableSize
,
BmpGetBits
UInt16 BmpColortableSize (BitmapType *bitmapP)
BmpBitsSize
,
BmpSize
,
BmpGetColortable
Err BmpCompress (BitmapType *bitmapP, BitmapCompressionType compType)
  |
-> |
Pointer to the bitmap to compress. (See BitmapType .) |
  |
-> |
The type of compression to use. (See BitmapCompressionType .) If set to BitmapCompressionTypeNone and bitmapP is compressed, this function uncompresses the bitmap. |
  |
|
Success. |
  |
|
Either the compType parameter does not specify a compression type or the bitmap is already compressed, is in the storage heap, or represents the screen. |
  |
|
There is not enough memory available to complete the operation. |
BitmapType *BmpCreate (Coord width, Coord height, UInt8 depth, ColorTableType *colortableP, UInt16 *error)
  |
-> |
The width of the bitmap in pixels. Must not be 0. |
  |
-> |
The height of the bitmap in pixels. Must not be 0. |
  |
-> |
The pixel depth of the bitmap. Must be 1, 2, 4 or 8. This value is used as the pixelSize field of BitmapType . |
  |
<- |
Contains the error code if an error occurs. |
BitmapType
) or NULL
if an error occurs. The parameter error
contains one of the following:
  |
|
Success. |
  |
|
The width , height , depth , or colorTableP parameter is invalid. See the descriptions above for acceptable values. |
  |
|
There is not enough memory available to allocate the structure. |
BitmapVersionTwo
bitmap with the width, height, and depth that you specify.
hasColorTable
flag is set. For performance reasons, attaching a custom color table to a bitmap is strongly discouraged. An alternative is to use the
WinPalette
command to change the color table as needed, draw the bitmap, and then undo your changes after you have finished displaying the bitmap.
WinCreateBitmapWindow
to create a offscreen window wrapper around the bitmap, then draw to that window:
BitmapType *bmpP;
WinHandle win;
Err error;
RectangleType onScreenRect;
bmpP = BmpCreate(10, 10, 8, NULL, &error);
if (bmpP) {
    win = WinCreateBitmapWindow(bmpP, &error);
    if (win) {
    WinSetDrawWindow(win);
    WinDrawLines(win, ...);
    /* etc */
    WinSetWindowBounds(win, onScreenRect);
    }
}
BmpCreate
to load a bitmap stored in a resource. Instead, you simply load the resource and lock its handle. The returned pointer is a pointer to a BitmapType
. For example:
MemHandle resH =
    DmGetResource (bitmapRsc, rscID);
BitmapType *bitmap = MemHandleLock (resH);
BmpDelete
Err BmpDelete (BitmapType *bitmapP)
errNone
upon success, sysErrParamErr
if the bitmap's forScreen
flag is set or the bitmap resides in the storage heap. Returns one of the memory errors if the freeing the pointer fails.
BmpCreate
.
void *BmpGetBits (BitmapType *bitmapP)
indirect
flag is set. (See
BitmapFlagsType
.)
BmpBitsSize
ColorTableType *BmpGetColortable (BitmapType *bitmapP)
NULL
if the bitmap uses the system color table.
BmpColortableSize
UInt16 BmpSize (BitmapType *bitmapP)
indirect
flag set (see
BitmapFlagsType
), the bitmap data is not included in the size returned by this function.
BmpBitsSize
,
BmpColortableSize
ColorTableEntries (ctP)
RGBColorType
structures, one for each entry in the color table.
BitmapType *bmpP;
RGBColorType *tableP =
    ColorTableEntries(BmpGetColorTable(bmpP));
WinPalette
function instead of this macro:
RGBColorType table;
Err e;
/* allocate space for table */
e = WinPalette(winPaletteGet, 0, 256, &table);
BmpGetColortable
  |   |