BALLOC(2G) BALLOC(2G) NAME balloc, bfree, rdbitmap, wrbitmap, rdbitmapfile, wrbitmapfile - allocating, freeing, reading, writing bitmaps SYNOPSIS #include <u.h> #include <libc.h> #include <libg.h> Bitmap *balloc(Rectangle r, int ldepth) void bfree(Bitmap *b) void rdbitmap(Bitmap *b, int miny, int maxy, uchar *data) void wrbitmap(Bitmap *b, int miny, int maxy, uchar *data) Bitmap *rdbitmapfile(int fd) void wrbitmapfile(int fd, Bitmap *b) DESCRIPTION A new bitmap is allocated with balloc; it will have the extent and ldepth (log base 2 of the number of bits per pixel) given by its arguments, and will be filled with zeros. The id field will have been set to the identifying number used by /dev/bitblt (see bit(3)), and the cache field will be zero. Balloc returns 0 if the server has run out of bitmap resources. Bfree frees the resources used by its argument bitmap. The remaining functions deal with moving groups of pixel values between bitmaps and user space or external files. There is a fixed format for the exchange and storage of bit- map data (see bitmap(6)). Rdbitmap reads rows of pixels from bitmap b into data. The rows read have y=ymin,ymin+1, ... ymax-1. Those rows must be within the range allowed by b.r. Wrbitmap replaces the specified rows of pixels in bitmap b with data. Rdbitmapfile creates a bitmap from data contained an exter- nal file (see bitmap(6) for the file format); fd is a file descriptor obtained by opening such a file for reading. The returned bitmap is allocated using balloc. Wrbitmapfile writes bitmap b onto file descriptor fd, which should be open for writing. The format is as described for Page 1 Plan 9 (printed 12/21/24) BALLOC(2G) BALLOC(2G) rdbitmapfile. Rdbitmapfile and wrbitmapfile do not close fd. SEE ALSO graphics(2), bitblt(2), bit(3), bitmap(6) DIAGNOSTICS These functions return 0 on failure, usually due to insuffi- cient memory. May set errstr. BUGS Ldepth must be 0, 1, 2, or 3. Page 2 Plan 9 (printed 12/21/24)