1 /* This code is ripped from Autotrace-0.29, but modified by pts. */
2 
3 /* bitmap.h: definition for a bitmap type.  No packing is done by
4    default; each pixel is represented by an entire byte.  Among other
5    things, this means the type can be used for both grayscale and binary
6    images. */
7 
8 #ifndef AT_BITMAP_H
9 #define AT_BITMAP_H
10 
11 #ifdef __GNUC__
12 #ifndef __clang__
13 #pragma interface
14 #endif
15 #endif
16 
17 #define PTS_SAM2P 1
18 #define FATALP(m) Error::sev(Error::EERROR) << m << (Error*)0;
19 #define WARNINGP(m) Error::sev(Error::WARNING) << m << (Error*)0;
20 #define FATALP1(m,a) Error::sev(Error::EERROR) << m << a << (Error*)0;
21 #define WARNINGP1(m,a) Error::sev(Error::WARNING) << m << a << (Error*)0;
22 #define FATALP3(m,a,n,b,o,c,p) Error::sev(Error::EERROR) << m << a << n << b << o << c << p << (Error*)0;
23 #define WARNINGP3(m,a,n,b,o,c,p) Error::sev(Error::WARNING) << m << n << b << o << c << p << (Error*)0;
24 
25 #define XMALLOCT(var,typep,size) var=(typep)new char[size]
26 #define XFREE(p) delete [] (char*)(p)
27 /* ^^^ Imp: arrays?? */
28 
29 typedef unsigned at_dimen_t; /**** pts ****/
30 
31 /* #include "autotrace.h" */
32 typedef char *at_string;
33 typedef struct _at_bitmap_type {
34   at_dimen_t height;
35   at_dimen_t width;
36   unsigned char *bitmap;
37   unsigned int np;
38 } at_bitmap_type;
39 
40 #include <stdio.h>
41 
42 #define xfclose(fd,dummy) fclose(fd)
43 
44 /* The basic structure and macros to access it.  */
45 typedef at_bitmap_type bitmap_type;
46 
47 /* The number of color planes of each pixel */
48 #define BITMAP_PLANES(b)  ((b).np)
49 
50 /* The pixels, represented as an array of bytes (in contiguous storage).
51    Each pixel is represented by np bytes.  */
52 #define BITMAP_BITS(b)  ((b).bitmap)
53 
54 /* These are convenient abbreviations for geting inside the members.  */
55 #define BITMAP_WIDTH(b)  ((b).width)
56 #define BITMAP_HEIGHT(b)  ((b).height)
57 
58 /* This is the pixel at [ROW,COL].  */
59 #define BITMAP_PIXEL(b, row, col)					\
60   ((BITMAP_BITS (b) + (row) * BITMAP_PLANES (b) * BITMAP_WIDTH (b)	\
61         + (col) * BITMAP_PLANES(b)))
62 
63 #define BITMAP_VALID_PIXEL(b, row, col)					\
64    	((row) < BITMAP_HEIGHT (b) && (col) < BITMAP_WIDTH (b))
65 
66 /* Allocate storage for the bits, set them all to white, and return an
67    initialized structure.  */
68 extern bitmap_type new_bitmap (at_dimen_t, at_dimen_t);
69 
70 /* Free that storage.  */
71 extern void free_bitmap (bitmap_type *);
72 
73 #endif /* not AT_BITMAP_H */
74