bitblt.h

Wed, 19 Feb 2003 10:20:05 +0000

author
eric
date
Wed, 19 Feb 2003 10:20:05 +0000
changeset 55
43a9b9f27403
parent 53
bb180150e603
child 57
b2a2f61135bb
permissions
-rw-r--r--

fix error reporting in process_specs(). rename some functions for clarity.

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