C code to manipulate bitmaps