gxbitfmt.h 7.1 KB

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