1 /* Copyright (C) 2001-2019 Artifex Software, Inc. 2 All Rights Reserved. 3 4 This software is provided AS-IS with no warranty, either express or 5 implied. 6 7 This software is distributed under license and may not be copied, 8 modified or distributed except as expressly authorized under the terms 9 of the license contained in the file LICENSE in this distribution. 10 11 Refer to licensing information at http://www.artifex.com or contact 12 Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, 13 CA 94945, U.S.A., +1(415)492-9861, for further information. 14 */ 15 16 17 /* Definitions for bitmap storage formats */ 18 19 #ifndef gxbitfmt_INCLUDED 20 # define gxbitfmt_INCLUDED 21 22 #include "stdpre.h" 23 24 /* 25 * Several operations, such as the get_bits_rectangle driver procedure, can 26 * take and/or produce data in a flexible variety of formats; the ability to 27 * describe how bitmap data is stored is useful in other contexts as well. 28 * We define bitmap storage formats using a bit mask: this allows a 29 * procedure to ask for, or offer to provide, data in more than one format. 30 */ 31 32 typedef ulong gx_bitmap_format_t; 33 34 /* 35 * Define the supported color space alternatives. 36 */ 37 38 #define GB_COLORS_NATIVE (1L<<0) /* native representation (DevicePixel) */ 39 #define GB_COLORS_GRAY (1L<<1) /* DeviceGray */ 40 #define GB_COLORS_RGB (1L<<2) /* DeviceRGB */ 41 #define GB_COLORS_CMYK (1L<<3) /* DeviceCMYK */ 42 43 #define GB_COLORS_STANDARD_ALL\ 44 (GB_COLORS_GRAY | GB_COLORS_RGB | GB_COLORS_CMYK) 45 #define GB_COLORS_ALL\ 46 (GB_COLORS_NATIVE | GB_COLORS_STANDARD_ALL) 47 #define GB_COLORS_NAMES\ 48 "colors_native", "colors_Gray", "colors_RGB", "colors_CMYK" 49 50 /* 51 * Define whether alpha information is included. For GB_COLORS_NATIVE, 52 * all values other than GB_ALPHA_NONE are equivalent. 53 */ 54 55 #define GB_ALPHA_NONE (1L<<4) /* no alpha */ 56 #define GB_ALPHA_FIRST (1L<<5) /* include alpha as first component */ 57 #define GB_ALPHA_LAST (1L<<6) /* include alpha as last component */ 58 /*unused*/ /*(1L<<7)*/ 59 60 #define GB_ALPHA_ALL\ 61 (GB_ALPHA_NONE | GB_ALPHA_FIRST | GB_ALPHA_LAST) 62 #define GB_ALPHA_NAMES\ 63 "alpha_none", "alpha_first", "alpha_last", "?alpha_unused?" 64 65 /* 66 * Define the supported depths per component for GB_COLORS_STANDARD. 67 * For GB_COLORS_NATIVE with planar packing, it is the client's 68 * responsibility to know how the device divides up the bits of the 69 * pixel. 70 */ 71 72 #define GB_DEPTH_1 (1L<<8) 73 #define GB_DEPTH_2 (1L<<9) 74 #define GB_DEPTH_4 (1L<<10) 75 #define GB_DEPTH_8 (1L<<11) 76 #define GB_DEPTH_12 (1L<<12) 77 #define GB_DEPTH_16 (1L<<13) 78 /*unused1*/ /*(1L<<14)*/ 79 /*unused2*/ /*(1L<<15)*/ 80 81 #define GB_DEPTH_ALL\ 82 (GB_DEPTH_1 | GB_DEPTH_2 | GB_DEPTH_4 | GB_DEPTH_8 |\ 83 GB_DEPTH_12 | GB_DEPTH_16) 84 #define GB_DEPTH_NAMES\ 85 "depth_1", "depth_2", "depth_4", "depth_8",\ 86 "depth_12", "depth_16", "?depth_unused1?", "?depth_unused2?" 87 88 /* Find the maximum depth of an options mask. */ 89 #define GB_OPTIONS_MAX_DEPTH(opt)\ 90 "\ 91 \000\001\002\002\004\004\004\004\010\010\010\010\010\010\010\010\ 92 \014\014\014\014\014\014\014\014\014\014\014\014\014\014\014\014\ 93 \020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\ 94 \020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\ 95 "[((opt) >> 8) & 0x3f] 96 /* Find the depth of an options mask with exactly 1 bit set. */ 97 #define GB_OPTIONS_DEPTH(opt)\ 98 ((((opt) >> 8) & 0xf) |\ 99 "\000\000\014\020"[((opt) >> 12) & 3]) 100 101 /* 102 * Define the supported packing formats. Currently, GB_PACKING_PLANAR is 103 * only partially supported, and GB_PACKING_BIT_PLANAR is hardly supported 104 * at all. 105 */ 106 107 #define GB_PACKING_CHUNKY (1L<<16) 108 #define GB_PACKING_PLANAR (1L<<17) /* 1 plane per component */ 109 #define GB_PACKING_BIT_PLANAR (1L<<18) /* 1 plane per bit */ 110 111 #define GB_PACKING_ALL\ 112 (GB_PACKING_CHUNKY | GB_PACKING_PLANAR | GB_PACKING_BIT_PLANAR) 113 #define GB_PACKING_NAMES\ 114 "packing_chunky", "packing_planar", "packing_bit_planar" 115 116 /* 117 * Define whether to return a subset of the planes. With planar packing 118 * formats, if this is set, only those planes that had non-zero data 119 * pointers originally will be returned (either by copying or by 120 * pointer). With chunky packing, if this is set, only an undefined 121 * subset of the returned bits may be valid. 122 */ 123 124 #define GB_SELECT_PLANES (1L<<19) 125 #define GB_SELECT_ALL\ 126 (GB_SELECT_PLANES) 127 #define GB_SELECT_NAMES\ 128 "select_planes" 129 130 /* 131 * Define the possible methods of returning data. 132 */ 133 134 #define GB_RETURN_COPY (1L<<20) /* copy to client's buffer */ 135 #define GB_RETURN_POINTER (1L<<21) /* return pointers to data */ 136 137 #define GB_RETURN_ALL\ 138 (GB_RETURN_COPY | GB_RETURN_POINTER) 139 #define GB_RETURN_NAMES\ 140 "return_copy", "return_pointer" 141 142 /* 143 * Define the allowable alignments. This is only relevant for 144 * GB_RETURN_POINTER: for GB_RETURN_COPY, any alignment is 145 * acceptable. 146 */ 147 148 #define GB_ALIGN_STANDARD (1L<<22) /* require standard bitmap alignment */ 149 #define GB_ALIGN_ANY (1L<<23) /* any alignment is acceptable */ 150 151 #define GB_ALIGN_ALL\ 152 (GB_ALIGN_ANY | GB_ALIGN_STANDARD) 153 #define GB_ALIGN_NAMES\ 154 "align_standard", "align_any" 155 156 /* 157 * Define the allowable X offsets. GB_OFFSET_ANY is only relevant for 158 * GB_RETURN_POINTER: for GB_RETURN_COPY, clients must specify 159 * the offset so they know how much space to allocate. 160 */ 161 162 #define GB_OFFSET_0 (1L<<24) /* no offsetting */ 163 #define GB_OFFSET_SPECIFIED (1L<<25) /* client-specified offset */ 164 #define GB_OFFSET_ANY (1L<<26) /* any offset is acceptable */ 165 /* (for GB_RETURN_POINTER only) */ 166 /*unused*/ /*(1L<<27)*/ 167 168 #define GB_OFFSET_ALL\ 169 (GB_OFFSET_0 | GB_OFFSET_SPECIFIED | GB_OFFSET_ANY) 170 #define GB_OFFSET_NAMES\ 171 "offset_0", "offset_specified", "offset_any", "?offset_unused?" 172 173 /* 174 * Define the allowable rasters. GB_RASTER_ANY is only relevant for 175 * GB_RETURN_POINTER, for the same reason as GB_OFFSET_ANY. 176 * Note also that if GB_ALIGN_STANDARD and GB_RASTER_SPECIFIED are 177 * both chosen and more than one scan line is being transferred, 178 * the raster value must also be aligned (i.e., 0 mod align_bitmap_mod). 179 * Implementors are not required to check this. 180 */ 181 182 /* 183 * Standard raster is bitmap_raster(dev->width) for return_ptr, 184 * bitmap_raster(x_offset + width) for return_copy, 185 * padding per alignment. 186 */ 187 #define GB_RASTER_STANDARD (1L<<28) 188 #define GB_RASTER_SPECIFIED (1L<<29) /* any client-specified raster */ 189 #define GB_RASTER_ANY (1L<<30) /* any raster is acceptable (for */ 190 /* GB_RETURN_POINTER only) */ 191 192 #define GB_RASTER_ALL\ 193 (GB_RASTER_STANDARD | GB_RASTER_SPECIFIED | GB_RASTER_ANY) 194 #define GB_RASTER_NAMES\ 195 "raster_standard", "raster_specified", "raster_any" 196 197 /* 198 * Return halftoned raster. (This requires a custom get_bit_rectangle 199 * device procedure. Most devices ignore this bit. 200 */ 201 #define GB_HALFTONED (1L<<31) 202 #define GB_HALFTONED_NAMES\ 203 "halftoned_no", "halftoned_yes" 204 205 /* Define names for debugging printout. */ 206 #define GX_BITMAP_FORMAT_NAMES\ 207 GB_COLORS_NAMES, GB_ALPHA_NAMES, GB_DEPTH_NAMES, GB_PACKING_NAMES,\ 208 GB_SELECT_NAMES, GB_RETURN_NAMES, GB_ALIGN_NAMES, GB_OFFSET_NAMES,\ 209 GB_RASTER_NAMES, GB_HALFTONE_NAMES 210 211 #endif /* gxbitfmt_INCLUDED */ 212