Bitmap Header Chunk
The <bmhd-ck> bitmap header chunk is defined as follows:
<bmhd-chunk> bmhd( struct {
ULONG ulMemSize; /* If ulPelFormat is 'data', only these */
ULONG ulPelFormat; /* four fields are present. */
USHORT wTransType;
ULONG ulTransVal;
ULONG ulHdrSize; /* Fields from ulHdrSize forward match */
ULONG ulWidth; /* the Windows BITMAPINFOHEADER */
ULONG ulHeight; /* structure, although some fields can */
USHORT ulPlanes; /* contain new values. */
USHORT usBitCount;
ULONG ulCompression;
ULONG ulSizeImage;
ULONG ulXPelsPerMeter;
ULONG ulYPelsPerMeter;
ULONG ulClrUsed;
ULONG ulClrImportant;
} )
If the ulCompression field equals BI_RGB or BI_RLE8 or BI_RLE4, then
the extended RDIB has the same bitmap format as a simple RDIB.
Each pixel format defines the orientation or position of the bitmap origin.
Windows bitmaps (identified by a value of data in the ulPelFormat
field) have the origin at the bottom left. By default, the other formats
have their origin at the top left.
Field
ulMemSize
Equal to the size of the bitmap bits if the
bits are uncompressed. For RDIBs with ulPelFormat equal to data,
ulMemSize has one of the following values:
Image Type
Non-RLE
Same as ulSizeImage value
8-bit
RLE
Size as an uncompressed, 8-bit image
4-bit
RLE
Size as an uncompressed, 4-bit image
ulPelFormat
Specifies a FOURCC code defining the pixel format
of the bitmap data. The bitmap data is stored in a chunk (or chunks) that
has the same chunk ID as contained in ulPelFormat. The compression
scheme and pixel depth of the bitmap data are recorded in the ulCompression
and ulBitCount fields. The current bitmap data values are as
follows:
Value
Bitmap Data Location and Format
data
Bitmap
data is stored in a data chunk using the format defined for Windows
3.0 device-independent bitmaps (DIBs). An application can display the bitmap
properly even if the fields after (and including) ulMemSize are ignored.
palb
Bitmap data
is stored in a palbchunk. The pixel format is one of the Windows
3.0 RGB palettized formats (1 to 8 bpp, depending on the value of the ulBitCount
field).
rgbb
Bitmap
data is stored in an rgbb chunk. Pixel format is packed, unpalettized
RGB represented at 16, 24, or 32 bits per pixel. The following table shows
the ordering of the RGB bits for each pixel-depth value. The first extra
bit (if present) is the high-order bit.
┌────────────────┬───────────┬───────────┬───────────┬───────────┐
│ulBitCount │Extra │Red │Green │Blue │
├────────────────┼───────────┼───────────┼───────────┼───────────┤
│15 │1 │5 │5 │5 │
├────────────────┼───────────┼───────────┼───────────┼───────────┤
│16 │0 │5 │6 │5 │
├────────────────┼───────────┼───────────┼───────────┼───────────┤
│24 │0 │8 │8 │8 │
├────────────────┼───────────┼───────────┼───────────┼───────────┤
│32 │8 │8 │8 │8 │
└────────────────┴───────────┴───────────┴───────────┴───────────┘
yuvb
Bitmap data
is stored in a yuvb chunk. Pixel format is packed, unpalettized YUV.
The exact pixel format is currently undefined. By the time this draft is
final, the pixel format will be defined similarly to the rgbb definition.
usTransType
Specifies
the type of transparency representation, if any, used for this image. This
is normally used for image overlay applications, where one image can be
on top of another visually, and all pels of the transparency color
must not be drawn. Examples include sprites, clip art, and motion video
overlay. Wherever the transparency color occurs in the picture, the background
must be visible.
This information is stored with the image, so that multiple images that
use the same color map can all have different transparency color. There
are five different values for the transparency variable. These are:
┌──────────────────────┬────────────────────────────────────────────────┐
│Value │Result │
├──────────────────────┼────────────────────────────────────────────────┤
│BITT_NONE (0x0000) │No pels are considered transparent in this │
│ │image. │
├──────────────────────┼────────────────────────────────────────────────┤
│BITT_MAPINDEX (0x0001)│One of the color map/palette entries must be │
│ │considered the transparency color. All │
│ │instances of this pel must not be drawn, and the│
│ │existing background must be allowed to show │
│ │through. │
├──────────────────────┼────────────────────────────────────────────────┤
│BITT_SINGLECOLOR │A single RGB or YUV value is considered │
│(0x0002) │transparent and must not be drawn. │
├──────────────────────┼────────────────────────────────────────────────┤
│BITT_BITPLANE (0x0003)│An individual bit plane is considered │
│ │transparent, and all pels that have that bit or │
│ │bits on must not be drawn. │
├──────────────────────┼────────────────────────────────────────────────┤
│BITT_MULTILEVEL │A set of bits indicate multiple levels of │
│(0x0004) │transparency or opacity. This is usually used │
│ │with 32-bit RGB, where the high 8 bits indicate │
│ │transparency. │
└──────────────────────┴────────────────────────────────────────────────┘
ulTransVal
These bytes allow
the image definition to indicate the exact information about the transparent
color. The information is dependent on the value of the wTransType as
follows:
wTransType
BITT_NONE
BITT_MAPINDEX
Specifies a palette index, either 0 through 16 or
0 through 255, depending on the number of palette entries.
BITT_SINGLECOLOR
Specifies an RGB or YUV value (2 to 4 bytes in size,
depending on the pixel format specified by ulPelFormat). All pels
that match ulTransVal should be considered transparent.
BITT_BITPLANE
Specifies a bit mask identifying the bits used to
indicate a transparent pel. Any pel that has this set of bits set is totally
transparent. This allows multiple colors to be considered transparent.
This method works for palettized images; in this case, the value refers
to a map entry that is considered transparent.
BITT_MULTILEVEL
Specifies bits to use for transparency levels. These
bits act as a mask on every pel, and each pel can be matched to the mask
to determine the transparency level for the pel.
For example, if ulTransVal has value 0xFF000000, then there are 256
levels of transparency. Each pel can be evaluated against the mask. If
the pel has a value FFxxxxxx, then it is fully transparent. If the pel
has a value 00xxxxxx, then it is fully visible. If the pel has a value
7Fxxxxxx, the the pel is half visible.
ulHdrSize
Specifies the size of the data portion of the
<bmhdr> chunk. This is always 40, the size of the BITMAPINFOHEADER
structure.
ulWidth
Specifies
the width of the DIB in pixels.
ulHeight
Specifies
the height of the DIB in pixels.
usPlanes
Specifies
the number of planes. This value is normally 1, but it can be 3 or 4 for
24-bit RGB and 32-bit RGB images, respectively. In a multiplane DIB, each
color component (for example, red, green, and blue) is stored as a separate
plane, and each plan is stored in a separate bitmap data chunk. For example,
in a 3-plane, 24-bit 'rgbb' bitmap, the red colors are stored in one 'rgbb'
chunk, the green colors in a second 'rgbb' chunk, and the blue colors in
a third 'rgbb' chunk.
Allowing the separate RGB planes to be compressed independently can dramatically
improve the compression ratio. The usPlanes value must be 1 if ulPelFormat
equals 'data'.
usBitCount
Specifies the number of bits per pixel. If the
ulPelFormat field equals 'data', this field must contain values
compatible with the Windows 3.0 DIB definition.
ulCompression
Specifies the type of compression for a compressed
bitmap. It can be one of the following values:
Value
BI_NONE
(0xFFFF0000)
Specifies that the bitmap is not compressed.
Pixel values are not padded to four-byte boundaries.
BI_RGB
(0x00000000)
Specifies that the bitmap is an uncompressed,
1-, 4-, 8-, or a 24-bit image. For 24-bit images, the palette is optional.
Bitmap bits are represented as defined by Windows 3.0 for BI_RGB DIBs.
The ulPelFormat field must be set to 'data'.
BI_RLE8
(0x00000001)
Specifies a run-length encoded, compressed
bitmap (as defined by Windows 3.0 BI_RLE8 DIBs). The palette is required.
The ulPelFormat field must be set to 'data'.
BI_RLE4
(0x00000002)
Specifies a run-length encoded, compressed
bitmap (as defined by Windows 3.0 BI_RLE4 DIBs). The palette is required.
The ulPelFormat field must be set to 'data'.
BI_PACK
(0xFFF0001)
Specifies a simple PACKBITS byte compression
scheme consisting of one-byte counts followed by byte data, in the form:
<count byte n><data byte1><data byte2>...
<data byte n>
<count byte n><data byte to repeat>
The high-order bit of the count byte n is a decision bit:
n Value
n
< 0x80
A run of n+1 non-repeating
bytes follows.
n > 0x80
Data
byte is repeated (n-0x80+1) times.
n
= 0x80
BI_TRANS
(0xFFFF0002)
BI_CCC
(0xFFFF0003)
Specifies CCC compression, a method
involving encoding each 4-by-4 block of the image using two colors.
BI_JPEGN
(0xFFFF0004)
To be defined later, when the ISO completes
the official specification.
ulSizeImage
Specifies the size in bytes of the compressed
image.
ulXPelsPerMeter
Specifies
the horizontal resolution in pixels per meter of the target device for the
bitmap. An application can use this value to select a bitmap from a resource
group that best matches the characteristics of the current device. This
field is set to zero if unused.
ulYPelsPerMeter
Specifies the vertical resolution in pixels
per meter of the target device for the bitmap. This field is set to zero
if unused.
ulClrUsed