bitblt.h

Fri, 14 Mar 2003 08:24:37 +0000

author
eric
date
Fri, 14 Mar 2003 08:24:37 +0000
changeset 131
4b8c80d77f76
parent 125
e2ef1c2f9eca
permissions
-rw-r--r--

finished implementing page labels.

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