#ifndef PACKED_PIXMAP_H_INCLUDED #define PACKED_PIXMAP_H_INCLUDED #include #include "pixmap.h" /* A pixmap backed by a packed bit map in memory. * * A packed bit map is a packed array of bytes (uint8_t) in which each * pixel of the image corresponds to a single bit of memory. * * The pixels are laid out as follows: each line corresponds to a * packed sequence of bytes. Let L be a pointer to the first byte * representing a line, then the pixel in position x=0 on that line is * the least significant bit in the first byte L[0], the pixel in * position x=7 corresponds to the most significant in L[0], the pixel * in position x=8 then corresponds to the least significant bit in * L[1], and so on. * * If the width of the packed_pixmap image is not a multiple of 8, then some * of the bits in the last byte of each line will be ignored. * * Lines are packed one after the other, with the first line * corresponding to the y=0 coordinate. * * HINT: you can set a bit in position i (i < 8) to 1 in a uint8_t * object x with the following code: * * uint8_t mask = 1; mask <<= i; x |= mask; * * or you can set it to 0 with the following code: * * uint8_t mask = 1; mask <<= i; x &= ~mask; */ struct packed_pixmap; /* Create a new packed pixmap backed by the given memory buffer. * * w is the number of characters in each line; h is the number of * lines; mem is a pointer to a memory region used to store the * pixels. This region is passed and owned by the user. It is also * assumed to be large enough to hold the packed pixel map. */ extern struct pixmap * packed_pixmap_new(unsigned int w, unsigned int h, uint8_t * mem); #endif