index.txt
BITMAP(6) Games Manual BITMAP(6) NAME bitmap - external format for bitmaps SYNOPSIS #include <libg.h> DESCRIPTION Bitmaps are described in graphics(2). Fonts and bitmaps are stored in external files in machine-independent formats. Bitmap files are read and written using rdbitmapfile and wrbitmapfile (see balloc(2)). A bitmap file starts with 5 decimal strings: ldepth, r.min.x, r.min.y, r.max.x, and r.max.y. Each number is right-justified and blank padded in 11 characters, followed by a blank. The rest of the file contains the r.max.y-r.min.y rows of bitmap data. A row con‐ sists of the byte containing pixel r.min.x and all the bytes up to and including the byte containing pixel r.max.x-1. A pixel with x-coordi‐ nate = x in a bitmap with ldepth = ld will appear as w = 2^ld contigu‐ ous bits in a byte, with the pixel's high order bit starting at the byte's bit number w*(x mod (8/w)), where bits within a byte are num‐ bered 0 to 7 from the high order to the low order bit. If w is greater than 8, it is a multiple of 8, so pixel values take up an integral num‐ ber of bytes. Rows contain integral number of bytes, so there may be some unused pixels at either end of a row. The rdbitmap and wrbitmap functions described in balloc(2) also deal with rows in this format, stored in user memory. Some small images, in particular 48×48 face files as used by seemail (see mail(1)) and 16×16 cursors, can be stored textually, suitable for inclusion in C source. Each line of text represents one scan line as a comma-separated sequence of hexadecimal bytes, shorts, or words in C format. For cursors, each line defines a pair of bytes. (It takes two images to define a cursor; each must be stored separately to be pro‐ cessed by programs such as tweak(1).) Face files of one bit per pixel are stored as a sequence of shorts, those of larger pixel sizes as a sequence of longs. Software that reads these files must deduce the im‐ age size from the input; there is no header. These formats reflect history rather than design. SEE ALSO tweak(1), graphics(2), bitblt(2), balloc(2), face(6), font(6) BITMAP(6)