1 /* Copyright (C) 1989, 1993, 1996, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. 2 3 This file is part of AFPL Ghostscript. 4 5 AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or 6 distributor accepts any responsibility for the consequences of using it, or 7 for whether it serves any particular purpose or works at all, unless he or 8 she says so in writing. Refer to the Aladdin Free Public License (the 9 "License") for full details. 10 11 Every copy of AFPL Ghostscript must include a copy of the License, normally 12 in a plain ASCII text file named PUBLIC. The License grants you the right 13 to copy, modify and redistribute AFPL Ghostscript, but only under certain 14 conditions described in the License. Among other things, the License 15 requires that the copyright notice and this notice be preserved on all 16 copies. 17 */ 18 19 /*$Id: gxbitmap.h,v 1.2 2000/09/19 19:00:33 lpd Exp $ */ 20 /* Definitions for stored bitmaps for Ghostscript */ 21 22 #ifndef gxbitmap_INCLUDED 23 # define gxbitmap_INCLUDED 24 25 #include "gstypes.h" /* for gs_id */ 26 #include "gsbitmap.h" 27 28 /* Define the gx version of a bitmap identifier. */ 29 typedef gs_bitmap_id gx_bitmap_id; 30 31 /* Define the gx version of the "no identifier" value. */ 32 #define gx_no_bitmap_id gs_no_bitmap_id 33 34 /* 35 * For gx_bitmap data, each scan line must start on a `word' (long) 36 * boundary, and hence is padded to a word boundary, although this should 37 * rarely be of concern, since the raster and width are specified 38 * individually. 39 */ 40 /* We assume arch_align_long_mod is 1-4 or 8. */ 41 #if arch_align_long_mod <= 4 42 # define log2_align_bitmap_mod 2 43 #else 44 #if arch_align_long_mod == 8 45 # define log2_align_bitmap_mod 3 46 #endif 47 #endif 48 #define align_bitmap_mod (1 << log2_align_bitmap_mod) 49 #define bitmap_raster(width_bits)\ 50 ((uint)((((width_bits) + (align_bitmap_mod * 8 - 1))\ 51 >> (log2_align_bitmap_mod + 3)) << log2_align_bitmap_mod)) 52 53 /* 54 * Define the gx analogue of the basic bitmap structure. Note that since 55 * all scan lines must be aligned, the requirement on raster is: 56 * If size.y > 1, 57 * raster >= bitmap_raster(size.x * depth) 58 * raster % align_bitmap_mod = 0 59 */ 60 #define gx_bitmap_common(data_type) gs_bitmap_common(data_type) 61 typedef struct gx_bitmap_s { 62 gx_bitmap_common(byte); 63 } gx_bitmap; 64 typedef struct gx_const_bitmap_s { 65 gx_bitmap_common(const byte); 66 } gx_const_bitmap; 67 68 /* 69 * Define the gx analogue of the tile bitmap structure. Note that if 70 * shift != 0 (for strip bitmaps, see below), size.y and rep_height 71 * mean something slightly different: see below for details. 72 */ 73 #define gx_tile_bitmap_common(data_type) gs_tile_bitmap_common(data_type) 74 typedef struct gx_tile_bitmap_s { 75 gx_tile_bitmap_common(byte); 76 } gx_tile_bitmap; 77 typedef struct gx_const_tile_bitmap_s { 78 gx_tile_bitmap_common(const byte); 79 } gx_const_tile_bitmap; 80 81 /* 82 * For halftones at arbitrary angles, we provide for storing the halftone 83 * data as a strip that must be shifted in X for different values of Y. For 84 * an ordinary (non-shifted) halftone that has a repetition width of W and a 85 * repetition height of H, the pixel at coordinate (X,Y) corresponds to 86 * halftone pixel (X mod W, Y mod H), ignoring phase; for a strip halftone 87 * with strip shift S and strip height H, the pixel at (X,Y) corresponds to 88 * halftone pixel ((X + S * floor(Y/H)) mod W, Y mod H). In other words, 89 * each Y increment of H shifts the strip left by S pixels. 90 * 91 * As for non-shifted tiles, a strip bitmap may include multiple copies 92 * in X or Y to reduce loop overhead. In this case, we must distinguish: 93 * - The height of an individual strip, which is the same as 94 * the height of the bitmap being replicated (rep_height, H); 95 * - The height of the entire bitmap (size.y). 96 * Similarly, we must distinguish: 97 * - The shift per strip (rep_shift, S); 98 * - The shift for the entire bitmap (shift). 99 * Note that shift = (rep_shift * size.y / rep_height) mod rep_width, 100 * so the shift member of the structure is only an accelerator. It is, 101 * however, an important one, since it indicates whether the overall 102 * bitmap requires shifting or not. 103 * 104 * Note that for shifted tiles, size.y is the size of the stored bitmap 105 * (1 or more strips), and NOT the height of the actual tile. The latter 106 * is not stored in the structure at all: it can be computed as H * W / 107 * gcd(S, W). 108 * 109 * If the bitmap consists of a multiple of W / gcd(S, W) copies in Y, the 110 * effective shift is zero, reducing it to a tile. For simplicity, we 111 * require that if shift is non-zero, the bitmap height be less than H * W / 112 * gcd(S, W). I.e., we don't allow strip bitmaps that are large enough to 113 * include a complete tile but that don't include an integral number of 114 * tiles. Requirements: 115 * rep_shift < rep_width 116 * shift = (rep_shift * (size.y / rep_height)) % rep_width 117 */ 118 #define gx_strip_bitmap_common(data_type)\ 119 gx_tile_bitmap_common(data_type);\ 120 ushort rep_shift;\ 121 ushort shift 122 typedef struct gx_strip_bitmap_s { 123 gx_strip_bitmap_common(byte); 124 } gx_strip_bitmap; 125 typedef struct gx_const_strip_bitmap_s { 126 gx_strip_bitmap_common(const byte); 127 } gx_const_strip_bitmap; 128 129 extern_st(st_gx_strip_bitmap); 130 #define public_st_gx_strip_bitmap() /* in gspcolor.c */\ 131 gs_public_st_suffix_add0_local(st_gx_strip_bitmap, gx_strip_bitmap,\ 132 "gx_strip_bitmap", bitmap_enum_ptrs, bitmap_reloc_ptrs,\ 133 st_gs_tile_bitmap) 134 #define st_gx_strip_bitmap_max_ptrs 1 135 136 #endif /* gxbitmap_INCLUDED */ 137