bitblt.h

Mon, 14 Dec 2009 16:18:21 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Mon, 14 Dec 2009 16:18:21 +0000
changeset 172
2fae6df568f6
parent 125
e2ef1c2f9eca
permissions
-rw-r--r--

remove erroneous 0.33-philpem1 tag

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