/* From http://paulbourke.net/dataformats/bmp/ Modified for UnixPC C console program A plain black and white bitmap requires only a single bit to document each pixel. the bitmap is monochrome, and the palette contains two entries. each bit in the bitmap array represents a pixel. if the bit is clear, the pixel is displayed with the color of the first entry in the palette; if the bit is set, the pixel has the color of the second entry in the table. This type of bitmap has a very small file size, and doesn't require a palette. based on program bmpsuite.c by Jason Summers http://entropymine.com/jason/bmpsuite/ Adam Majewski fraktal.republika.pl */ #include #include unsigned short bswap16(unsigned short a) { a = ((a & 0x00FF) << 8) | ((a & 0xFF00) >> 8); return a; } unsigned int bswap32(unsigned int a) { a = ((a & 0x000000FF) << 24) | ((a & 0x0000FF00) << 8) | ((a & 0x00FF0000) >> 8) | ((a & 0xFF000000) >> 24); return a; } /* width, height in pixels */ int pf1bit_bmp(char *fn, unsigned long Width, unsigned long Height, unsigned char bytes[]) { static unsigned char byte[1]; /* 1 byte = 8 bits */ unsigned short word[1]; /* 2 bytes */ unsigned long dword[1], /* 4 bytes */ bpp=1, /* in bytes */ FileHeaderSize=14, InfoHeaderSize=40, /* header_bytes */ PaletteSize=(1<