libkate: Format - bitmap

# Format - bitmap

A bitmap definition consists of:

- a variable length integer representing the width of the bitmap in pixels.
- a variable length integer representing the height of the bitmap in pixels.
- 8 bits representing the number of bits per pixel for this bitmap (values not in the 0-7 range are an error).

Then, if the number of bits per pixel is zero:

- 8 bits representing the type of the bitmap.

For type 0 (paletted bitmap):

- 8 bits for the encoding of this bitmap

For encoding 1 (RLE encoding):

- a variable length integer for the number of bits per pixel.
- a variable length integer for the index of the default palette to use for this bitmap (-1 if none)
- a RLE encoded bitmap.

All other encodings are reserved. If one is encountered, the bitmap cannot be decoded.

For type 1 (PNG bitmap):

- 32 bits for the number of bytes used for this bitmap's data.
- That number of bytes, interpreted as a raw PNG stream.

All other types are reserved. If one is encountered, the bitmap cannot be decoded.

If the number of bits per pixel is greater than zero (deprecated):

- a variable length integer representing the index of the default palette to use for this bitmap (-1 for no default palette).
- a stream of bits representing the pixel indices for this bitmap, rows first, packed (eg, N bits for the first pixel, N bits for the second one, etc, N being the number of bits per pixel specified above)

Next, we have a warp.

Bitstream version 0.4 starts making use of this warp:

- a variable length integer representing the horizontal offset to the logical center of the bitmap.
- a variable length integer representing the vertical offset to the logical center of the bitmap.

Kate bitstream 0.6 makes further use of this warp to add:

- a metadata set.

Next, the data ends.