1
0
mirror of synced 2026-04-26 20:26:55 +00:00
Files
brouhaha.tumble/bitblt.h
2002-08-26 06:03:55 +00:00

72 lines
1.2 KiB
C

typedef struct Point
{
int32_t x;
int32_t y;
} Point;
typedef struct Rect
{
Point min;
Point max;
} Rect;
static inline int32_t rect_width (Rect *r)
{
return (r->max.x - r->min.x);
}
static inline int32_t rect_height (Rect *r)
{
return (r->max.y - r->min.y);
}
typedef uint32_t word_type;
#define BITS_PER_WORD (8 * sizeof (word_type))
#define ALL_ONES (~ 0U)
typedef struct Bitmap
{
word_type *bits;
Rect rect;
uint32_t row_words;
} Bitmap;
#define TF_SRC 0xc
#define TF_AND 0x8
#define TF_OR 0xe
#define TF_XOR 0x6
Bitmap *create_bitmap (Rect *rect);
void free_bitmap (Bitmap *bitmap);
bool get_pixel (Bitmap *bitmap, Point coord);
void set_pixel (Bitmap *bitmap, Point coord, bool value);
Bitmap *bitblt (Bitmap *src_bitmap,
Rect *src_rect,
Bitmap *dest_bitmap,
Point *dest_min,
int tfn,
int background);
/* in-place transformations */
void flip_h (Bitmap *src);
void flip_v (Bitmap *src);
void rot_180 (Bitmap *src); /* combination of flip_h and flip_v */
/* "in-place" transformations - will allocate new memory and free old */
void transpose (Bitmap *src);
void rot_90 (Bitmap *src); /* transpose + flip_h */
void rot_270 (Bitmap *src); /* transpose + flip_v */
void reverse_bits (uint8_t *p, int byte_count);