Wed, 19 Feb 2003 10:14:49 +0000
rename br.c to bitblt_table_gen.c, and integrate use of it into build process
1 /*
2 * t2p: Create a PDF file from the contents of one or more TIFF
3 * bilevel image files. The images in the resulting PDF file
4 * will be compressed using ITU-T T.6 (G4) fax encoding.
5 *
6 * bitblt routines
7 * $Id: bitblt.h,v 1.10 2003/02/19 02:14:44 eric Exp $
8 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. Note that permission is
13 * not granted to redistribute this program under the terms of any
14 * other version of the General Public License.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
24 */
27 typedef struct Point
28 {
29 int32_t x;
30 int32_t y;
31 } Point;
33 typedef struct Rect
34 {
35 Point min;
36 Point max;
37 } Rect;
39 static inline int32_t rect_width (Rect *r)
40 {
41 return (r->max.x - r->min.x);
42 }
44 static inline int32_t rect_height (Rect *r)
45 {
46 return (r->max.y - r->min.y);
47 }
50 typedef uint32_t word_type;
51 #define BITS_PER_WORD (8 * sizeof (word_type))
52 #define ALL_ONES (~ 0U)
55 typedef struct Bitmap
56 {
57 word_type *bits;
58 Rect rect;
59 uint32_t row_words;
60 } Bitmap;
63 #define TF_SRC 0xc
64 #define TF_AND 0x8
65 #define TF_OR 0xe
66 #define TF_XOR 0x6
69 void bitblt_init (void);
72 Bitmap *create_bitmap (Rect *rect);
73 void free_bitmap (Bitmap *bitmap);
75 bool get_pixel (Bitmap *bitmap, Point coord);
76 void set_pixel (Bitmap *bitmap, Point coord, bool value);
79 Bitmap *bitblt (Bitmap *src_bitmap,
80 Rect *src_rect,
81 Bitmap *dest_bitmap,
82 Point *dest_min,
83 int tfn,
84 int background);
87 /* in-place transformations */
88 void flip_h (Bitmap *src);
89 void flip_v (Bitmap *src);
91 void rot_180 (Bitmap *src); /* combination of flip_h and flip_v */
93 /* "in-place" transformations - will allocate new memory and free old */
94 void transpose (Bitmap *src);
96 void rot_90 (Bitmap *src); /* transpose + flip_h */
97 void rot_270 (Bitmap *src); /* transpose + flip_v */
100 void reverse_bits (uint8_t *p, int byte_count);