#ifndef BITMAP_H #define BITMAP_H #include #include #include enum rgb {red, green, blue, rgb}; enum rgba {alpha = rgb, rgba}; enum cmyk {cyan, magenta, yellow, black, cmyk}; enum grey {level, grey}; typedef union { uint8_t bytes[4]; uint8_t cmyk[cmyk]; uint8_t rgba[rgba]; uint8_t rgb[rgb]; uint8_t grey[grey]; } colour; static_assert(sizeof (colour) == sizeof (colour){0}.bytes, ""); struct bitmap { size_t width; size_t height; colour clear; enum depth {mono1, grey8, index8, rgb24, rgba32, cmyk32} depth; uint8_t data[]; }; struct bitmap *clearbitmap(struct bitmap *, colour); struct bitmap *createbitmap(struct bitmap); colour getbitmap(const struct bitmap *, size_t, size_t); struct bitmap *destroybitmap(struct bitmap *); struct memory {size_t size; uint8_t *bytes;} exportbitmap(struct bitmap *); struct bitmap *setbitmap(struct bitmap *, size_t, size_t, colour); #endif