File: at_bitmap.h

package info (click to toggle)
sam2p 0.45-3-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,300 kB
  • ctags: 3,184
  • sloc: cpp: 14,145; ansic: 8,996; tcl: 973; sh: 716; makefile: 238; perl: 67
file content (70 lines) | stat: -rw-r--r-- 2,331 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* This code is ripped from Autotrace-0.29, but modified by pts. */

/* bitmap.h: definition for a bitmap type.  No packing is done by
   default; each pixel is represented by an entire byte.  Among other
   things, this means the type can be used for both grayscale and binary
   images. */

#ifndef AT_BITMAP_H
#define AT_BITMAP_H

#ifdef __GNUC__
#pragma interface
#endif

#define PTS_SAM2P 1
#define FATALP(m) Error::sev(Error::EERROR) << m << (Error*)0;
#define WARNINGP(m) Error::sev(Error::WARNING) << m << (Error*)0;
#define FATALP1(m,a) Error::sev(Error::EERROR) << m << a << (Error*)0;
#define WARNINGP1(m,a) Error::sev(Error::WARNING) << m << a << (Error*)0;
#define FATALP3(m,a,n,b,o,c,p) Error::sev(Error::EERROR) << m << a << n << b << o << c << p << (Error*)0;
#define WARNINGP3(m,a,n,b,o,c,p) Error::sev(Error::WARNING) << m << n << b << o << c << p << (Error*)0;

#define XMALLOCT(var,typep,size) var=(typep)new char[size]
#define XMALLOCTU(var,type) var=(type*)new type
#define XFREE(p) delete p
/* ^^^ Imp: arrays?? */

/* #include "autotrace.h" */
typedef char *at_string;
typedef struct _at_bitmap_type {
  unsigned short height;
  unsigned short width;
  unsigned char *bitmap;
  unsigned int np;
} at_bitmap_type;

#include <stdio.h>

#define xfclose(fd,dummy) fclose(fd)

/* The basic structure and macros to access it.  */
typedef at_bitmap_type bitmap_type;

/* The number of color planes of each pixel */
#define BITMAP_PLANES(b)  ((b).np)

/* The pixels, represented as an array of bytes (in contiguous storage).
   Each pixel is represented by np bytes.  */
#define BITMAP_BITS(b)  ((b).bitmap)

/* These are convenient abbreviations for geting inside the members.  */
#define BITMAP_WIDTH(b)  ((b).width)
#define BITMAP_HEIGHT(b)  ((b).height)

/* This is the pixel at [ROW,COL].  */
#define BITMAP_PIXEL(b, row, col)					\
  ((BITMAP_BITS (b) + (row) * BITMAP_PLANES (b) * BITMAP_WIDTH (b)	\
        + (col) * BITMAP_PLANES(b)))

#define BITMAP_VALID_PIXEL(b, row, col)					\
   	((row) < BITMAP_HEIGHT (b) && (col) < BITMAP_WIDTH (b))

/* Allocate storage for the bits, set them all to white, and return an
   initialized structure.  */
extern bitmap_type new_bitmap (unsigned short, unsigned short);

/* Free that storage.  */
extern void free_bitmap (bitmap_type *);

#endif /* not AT_BITMAP_H */