Tue, 22 Jan 2002 09:42:42 +0000
*** empty log message ***
eric@2 | 1 | typedef struct Point |
eric@2 | 2 | { |
eric@35 | 3 | s32 x; |
eric@35 | 4 | s32 y; |
eric@2 | 5 | } Point; |
eric@2 | 6 | |
eric@2 | 7 | typedef struct Rect |
eric@2 | 8 | { |
eric@42 | 9 | Point min; |
eric@42 | 10 | Point max; |
eric@2 | 11 | } Rect; |
eric@2 | 12 | |
eric@42 | 13 | static inline s32 rect_width (Rect *r) |
eric@42 | 14 | { |
eric@42 | 15 | return (r->max.x - r->min.x); |
eric@42 | 16 | } |
eric@42 | 17 | |
eric@42 | 18 | static inline s32 rect_height (Rect *r) |
eric@42 | 19 | { |
eric@42 | 20 | return (r->max.y - r->min.y); |
eric@42 | 21 | } |
eric@42 | 22 | |
eric@43 | 23 | /* |
eric@43 | 24 | * Despite the following two definitions, there are still some places |
eric@43 | 25 | * in the code that depend on words having 32 bits. |
eric@43 | 26 | */ |
eric@43 | 27 | #define BITS_PER_WORD 32 |
eric@43 | 28 | typedef u32 word_type; |
eric@43 | 29 | |
eric@2 | 30 | typedef struct Bitmap |
eric@2 | 31 | { |
eric@43 | 32 | word_type *bits; |
eric@42 | 33 | Rect rect; |
eric@43 | 34 | u32 row_words; |
eric@2 | 35 | } Bitmap; |
eric@2 | 36 | |
eric@2 | 37 | |
eric@2 | 38 | #define TF_SRC 0xc |
eric@2 | 39 | #define TF_AND 0x8 |
eric@2 | 40 | #define TF_OR 0xe |
eric@2 | 41 | #define TF_XOR 0x6 |
eric@2 | 42 | |
eric@2 | 43 | |
eric@42 | 44 | Bitmap *create_bitmap (Rect *rect); |
eric@42 | 45 | void free_bitmap (Bitmap *bitmap); |
eric@3 | 46 | |
eric@2 | 47 | boolean get_pixel (Bitmap *bitmap, Point coord); |
eric@2 | 48 | void set_pixel (Bitmap *bitmap, Point coord, boolean value); |
eric@2 | 49 | |
eric@42 | 50 | |
eric@2 | 51 | Bitmap *bitblt (Bitmap *src_bitmap, |
eric@42 | 52 | Rect *src_rect, |
eric@2 | 53 | Bitmap *dest_bitmap, |
eric@42 | 54 | Point *dest_min, |
eric@43 | 55 | int tfn, |
eric@43 | 56 | int background); |
eric@42 | 57 | |
eric@42 | 58 | |
eric@42 | 59 | /* in-place transformations */ |
eric@42 | 60 | void flip_h (Bitmap *src); |
eric@42 | 61 | void flip_v (Bitmap *src); |
eric@42 | 62 | |
eric@42 | 63 | void rot_180 (Bitmap *src); /* combination of flip_h and flip_v */ |
eric@42 | 64 | |
eric@42 | 65 | /* "in-place" transformations - will allocate new memory and free old */ |
eric@42 | 66 | void transpose (Bitmap *src); |
eric@42 | 67 | |
eric@42 | 68 | void rot_90 (Bitmap *src); /* transpose + flip_h */ |
eric@42 | 69 | void rot_270 (Bitmap *src); /* transpose + flip_v */ |