Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

279 lines
6.8 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998-2000 Microsoft Corporation
  4. *
  5. * Abstract:
  6. *
  7. * Internal output banding class for use with printing.
  8. *
  9. * This class supports two major forms of DIB banding. Both are useful
  10. * when printing.
  11. *
  12. * 1. Output at a 'capped DPI' either 32bpp or 24bpp.
  13. * 2. Output at a 'device DPI' only the alpha channel.
  14. *
  15. * Revision History:
  16. *
  17. * 07/26/1999 ericvan
  18. * Created it.
  19. *
  20. \**************************************************************************/
  21. #ifndef __SCANDIB_HPP
  22. #define __SCANDIB_HPP
  23. // Internally generate a bottom up DIB
  24. #define PRINT_BOTTOM_UP 1
  25. enum ScanDIBOptions
  26. {
  27. ScanCappedBounds = 0x00000001, // allocate 24bpp buffer at capped size
  28. ScanDeviceBounds = 0x00000002, // allocate 1bpp mask at device size
  29. ScanCapped32bpp = 0x00000004, // otherwise the default is 24bpp
  30. ScanCapped32bppOver = 0x00000008, // otherwise the default is 24bpp
  31. ScanCappedOver = 0x00000010, // do whiteness source over on 24bpp
  32. ScanDeviceZeroOut = 0x00000020, // zero out 0's in capped buffer when
  33. // generating 0's in alpha mask buffer
  34. // !! ONLY if dev/cap is integer.
  35. ScanDeviceAlpha = 0x00000040, // generate alpha vs. opaque 1bpp mask
  36. ScanBleedOut = 0x00000080, // bleed color data
  37. ScanDeviceFlags = ScanDeviceAlpha | ScanDeviceZeroOut | ScanDeviceBounds,
  38. ScanCappedFlags = ScanCappedBounds | ScanCapped32bpp | ScanCappedOver |
  39. ScanCapped32bppOver
  40. };
  41. class EpScanDIB : public EpScan
  42. {
  43. private:
  44. GpRect CappedBounds; // bounds at capped DPI (24bpp)
  45. GpRect DeviceBounds; // bounds at device DPI (1bpp)
  46. INT CappedStride;
  47. GpPoint MinBound;
  48. GpPoint MaxBound;
  49. INT ScaleX;
  50. INT ScaleY;
  51. // Last output scan operation
  52. INT OutputX, OutputY, OutputWidth, OutputBleed, OutputLastY;
  53. // 32bpp/24bpp DIB section
  54. BYTE* BufStart;
  55. ARGB* Buf32bpp;
  56. ARGB* CurBuffer;
  57. struct {
  58. BITMAPINFO BMI;
  59. RGBQUAD rgbQuad[4];
  60. } Buf;
  61. // Transparency mask
  62. BYTE* MaskStart;
  63. INT MaskStride; // # of bytes in one stride
  64. struct {
  65. BITMAPINFO BMI;
  66. RGBQUAD rgbQuad[4];
  67. } Mask;
  68. // pointer to 32bpp scanline which we halftone FROM into the 1bpp mask above
  69. ARGB* AlphaStart;
  70. // array for keeping count for zeroing out scans of capped image
  71. BYTE* ZeroStart;
  72. NEXTBUFFERFUNCTION NextBuffer;
  73. DWORD ScanOptions;
  74. BOOL RenderAlpha;
  75. BOOL Rasterizing;
  76. // padding of pixels that we don't zeroout.
  77. INT ZeroOutPad;
  78. private:
  79. // output at capped dpi at 32bpp
  80. VOID *NextBufferFunc32bpp(
  81. INT x,
  82. INT y,
  83. INT newWidth,
  84. INT updateWidth,
  85. INT blenderNum
  86. );
  87. // output at capped dpi at 32bpp
  88. VOID *NextBufferFunc32bppOver(
  89. INT x,
  90. INT y,
  91. INT newWidth,
  92. INT updateWidth,
  93. INT blenderNum
  94. );
  95. // output at capped dpi at 24bpp
  96. VOID *NextBufferFunc24bpp(
  97. INT x,
  98. INT y,
  99. INT newWidth,
  100. INT updateWidth,
  101. INT blenderNum
  102. );
  103. // output at capped dpi at 24bpp
  104. VOID *NextBufferFunc24bppBleed(
  105. INT x,
  106. INT y,
  107. INT newWidth,
  108. INT updateWidth,
  109. INT blenderNum
  110. );
  111. // output at capped dpi at 24bpp, does implicit alpha blend on white
  112. // surface
  113. VOID *NextBufferFunc24bppOver(
  114. INT x,
  115. INT y,
  116. INT newWidth,
  117. INT updateWidth,
  118. INT blenderNum
  119. );
  120. // output alpha mask at device dpi at 1bpp
  121. VOID *NextBufferFuncAlpha(
  122. INT x,
  123. INT y,
  124. INT newWidth,
  125. INT updateWidth,
  126. INT blenderNum
  127. );
  128. // output opaque mask at device dpi at 1bpp
  129. VOID *NextBufferFuncOpaque(
  130. INT x,
  131. INT y,
  132. INT newWidth,
  133. INT updateWidth,
  134. INT blenderNum
  135. );
  136. // doesn't output a mask, but zero's out clipped portions of 24bpp DIB
  137. VOID *NextBufferFuncZeroOut(
  138. INT x,
  139. INT y,
  140. INT newWidth,
  141. INT updateWidth,
  142. INT blenderNum
  143. );
  144. public:
  145. EpScanDIB();
  146. ~EpScanDIB() {}
  147. virtual BOOL Start(
  148. DpDriver *driver,
  149. DpContext *context,
  150. DpBitmap *surface,
  151. NEXTBUFFERFUNCTION *nextBuffer,
  152. EpScanType scanType,
  153. PixelFormatID pixFmtGeneral,
  154. PixelFormatID pixFmtOpaque,
  155. ARGB solidColor
  156. );
  157. VOID End(INT updateWidth);
  158. VOID Flush();
  159. // ARGB buffer
  160. BYTE *GetStartBuffer()
  161. {
  162. return BufStart;
  163. }
  164. BITMAPINFO *GetBufferBITMAPINFO()
  165. {
  166. return &Buf.BMI;
  167. }
  168. DWORD GetBufferStride()
  169. {
  170. return CappedStride;
  171. }
  172. // Mask Buffer
  173. BYTE *GetMaskBuffer()
  174. {
  175. return MaskStart;
  176. }
  177. DWORD GetMaskStride()
  178. {
  179. return MaskStride;
  180. }
  181. BITMAPINFO *GetMaskBITMAPINFO()
  182. {
  183. return &Mask.BMI;
  184. }
  185. VOID *GetCurrentBuffer()
  186. {
  187. return CurBuffer;
  188. }
  189. virtual BYTE* GetCurrentCTBuffer()
  190. {
  191. // Since this class is meant for printers, higher-level
  192. // code should prevent us from getting here.
  193. // GpGraphics::GetTextRenderingHintInternal() guards against this.
  194. ASSERT(FALSE);
  195. return NULL;
  196. }
  197. DWORD GetOptions()
  198. {
  199. return ScanOptions;
  200. }
  201. BOOL GetActualBounds(GpRect *rect);
  202. VOID SetRenderMode(BOOL RenderAlpha, GpRect* newBounds);
  203. // Allocate DIB and monochrome DIB memory
  204. GpStatus CreateBufferDIB(const GpRect* boundsCap,
  205. const GpRect* boundsDev,
  206. DWORD scanDIBOptions,
  207. INT scaleX,
  208. INT scaleY);
  209. VOID DestroyBufferDIB();
  210. INT GetZeroOutPad()
  211. {
  212. return ZeroOutPad;
  213. }
  214. VOID SetZeroOutPad(INT pad)
  215. {
  216. ASSERT(pad >= 0);
  217. ZeroOutPad = pad;
  218. }
  219. VOID ResetZeroOutPad()
  220. {
  221. ZeroOutPad = 2;
  222. }
  223. #if 0
  224. // create 1bpp monochrome mask of DIB
  225. GpStatus CreateAlphaMask();
  226. // create simple opaque monochrome mask of DIB (alpha>0 => opaque)
  227. GpStatus CreateOpaqueMask(); // not used
  228. #endif
  229. };
  230. #endif