| 1 |
/* bitmap.h: definition for a bitmap type. No packing is done by |
| 2 |
default; each pixel is represented by an entire byte. Among other |
| 3 |
things, this means the type can be used for both grayscale and binary |
| 4 |
images. */ |
| 5 |
|
| 6 |
#ifndef BITMAP_H |
| 7 |
#define BITMAP_H |
| 8 |
|
| 9 |
#include "autotrace.h" |
| 10 |
#include <stdio.h> |
| 11 |
|
| 12 |
/* at_ prefix removed version */ |
| 13 |
typedef at_bitmap_type bitmap_type; |
| 14 |
#define BITMAP_PLANES(b) AT_BITMAP_PLANES(b) |
| 15 |
#define BITMAP_BITS(b) AT_BITMAP_BITS(b) |
| 16 |
#define BITMAP_WIDTH(b) AT_BITMAP_WIDTH(b) |
| 17 |
#define BITMAP_HEIGHT(b) AT_BITMAP_HEIGHT(b) |
| 18 |
|
| 19 |
/* This is the pixel at [ROW,COL]. */ |
| 20 |
#define BITMAP_PIXEL(b, row, col) \ |
| 21 |
((b).bitmap + ((row) * (b).width + (col)) * (b).np) |
| 22 |
|
| 23 |
#define BITMAP_VALID_PIXEL(b, row, col) \ |
| 24 |
((row) < (b).height && (col) < (b).width) |
| 25 |
|
| 26 |
/* Allocate storage for the bits, set them all to white, and return an |
| 27 |
initialized structure. */ |
| 28 |
extern bitmap_type new_bitmap (unsigned short width, unsigned short height); |
| 29 |
|
| 30 |
/* Free that storage. */ |
| 31 |
extern void free_bitmap (bitmap_type *); |
| 32 |
|
| 33 |
|
| 34 |
at_bitmap_type * at_bitmap_new(unsigned short width, |
| 35 |
unsigned short height, |
| 36 |
unsigned int planes); |
| 37 |
at_bitmap_type * at_bitmap_copy(at_bitmap_type * src); |
| 38 |
|
| 39 |
/* We have to export functions that allows internal datum |
| 40 |
access. Such functions might be useful for |
| 41 |
at_bitmap_new user. */ |
| 42 |
unsigned short at_bitmap_get_width (at_bitmap_type * bitmap); |
| 43 |
unsigned short at_bitmap_get_height (at_bitmap_type * bitmap); |
| 44 |
unsigned short at_bitmap_get_planes (at_bitmap_type * bitmap); |
| 45 |
void at_bitmap_free (at_bitmap_type * bitmap); |
| 46 |
|
| 47 |
at_bitmap_type |
| 48 |
at_bitmap_init(unsigned char * area, |
| 49 |
unsigned short width, |
| 50 |
unsigned short height, |
| 51 |
unsigned int planes); |
| 52 |
|
| 53 |
#endif /* not BITMAP_H */ |