bitblt.h

Thu, 20 Feb 2003 12:20:28 +0000

author
eric
date
Thu, 20 Feb 2003 12:20:28 +0000
changeset 60
ffb5b1e54eb2
parent 57
b2a2f61135bb
child 72
cddd6226b509
permissions
-rw-r--r--

fix includes.

     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.11 2003/02/20 04:11:06 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);
   103 /*
   104  * get_row_run_lengths counts the runs of 0 and 1 bits in row
   105  * y of a bitmap, from min_x through max_x inclusive.  The run lengths
   106  * will be stored in the run_length array.  The first entry will be
   107  * the length of a zero run (which length may be zero, if the first
   108  * bit is a one).  The next entry will the be the length of a run of
   109  * ones, and they will alternate from there, with even entries representing
   110  * runs of zeros, and odd entries representing runs of ones.
   111  *
   112  * max_runs should be set to the maximum number of run lengths that
   113  * can be stored in the run_length array.
   114  *
   115  * Returns the actual number of runs counted, or -max_runs if there
   116  * was not enough room in the array.
   117  */
   118 int32_t get_row_run_lengths (Bitmap *src,
   119 			     int32_t y,
   120 			     int32_t min_x, int32_t max_x,
   121 			     int32_t max_runs,
   122 			     uint32_t *run_length);