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.

315 lines
14 KiB

  1. ///////////////////////////////////////////////////////////////////////
  2. //
  3. // BitBlt.H - Contains the BitBlt prototypes
  4. //
  5. // Copyright (c) 1994 Microsoft Corporation
  6. //
  7. // History:
  8. // 10/18/94 - Scott Leatham Created it w/8BPP support only
  9. // 10/19/94 - Olivier Garamfalvi Chopped out unneeded stuff
  10. // 05/30/95 - Myron Thomas Code clean up
  11. //
  12. ///////////////////////////////////////////////////////////////////////
  13. #ifdef NT_BUILD_ENVIRONMENT
  14. typedef ULONG SCODE;
  15. typedef long HRESULT;
  16. #endif
  17. #ifdef MMOSA
  18. //#include <pshpack1.h>
  19. typedef struct tagRGBTRIPLE {
  20. BYTE rgbtBlue;
  21. BYTE rgbtGreen;
  22. BYTE rgbtRed;
  23. } RGBTRIPLE;
  24. //#include <poppack.h>
  25. #endif
  26. // Bits Per Pixel Formats
  27. // HIBYTE=Penguin Image Format specifier, FF = not supported by Penguin
  28. // LOBYTE=PhysicalBitsPerPixel, FF = not support by bitblt
  29. #define BPP_MSK_BITCOUNT 0x00ff // Get the bitcount from a BPP_ constant
  30. #define BPP_MSK_IMAGECODE 0xff00 // Get the Penguin IMage code from a BPP_ constant
  31. #define BPP_INVALID 0xffff // LO = 256 & HI = 256 = Bad format
  32. #define BPP_1_MONOCHROME 0xff01 // LO = 256 bpp, HI = 1 bit monochrome not supported on Penguin
  33. #define BPP_2_4GRAYSCALE 0xff02 // LO = 256 bpp, HI = 2 bits 4 shades of gray not supported on Penguin
  34. #define BPP_4_16GRAYSCALE 0xff04 // LO = 256 bpp, HI = 4 bits 16 shades of gray not supported on Penguin
  35. #define BPP_8_PALETTEIDX 0x0008 // LO = 8 bpp, HI = Penguin H/W code 000 = 8 bits 256 colors palette indexed
  36. #define BPP_16_FILLSPAN 0x01FF // LO = 256bpp, HI = Penguin H/W code 001 (SrcAdr of span desc. if used as an RGB value
  37. #define BPP_16_8WALPHA 0x0510 // LO = 16 bpp, HI = Penguin H/W code 101 = 8 bits 256 colors palette indexed, 8 bits alpha
  38. #define BPP_16_RGB 0x0610 // LO = 16 bpp, HI = Penguin H/W code 110 = 16 bits used for RGB in 5-6-5 format
  39. #define BPP_16_YCRCB 0x0710 // LO = 16 bpp, HI = Penguin H/W code 111 = 16 bits Cr Cb Sample and subsample 2 bytes at a time
  40. #define BPP_24_RGBPACKED 0xff18 // LO = 256 bpp, HI = 24 bit RGB not supported by Penguin
  41. #define BPP_24_RGB 0x0220 // LO = 32 bpp, HI = Penguin H/W code 010 = 24 bits used for RGB color and 8 empty bits
  42. #define BPP_32_24WALPHA 0x0320 // LO = 32 bpp, HI = Penguin H/W code 011 = 24 bits used for RGB color and 8 bit alpha byte
  43. // New Bit Compression Values:
  44. #define BI_RGBA 4L
  45. #define BI_YCRCB 5L
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. SCODE BlitLib_BitBlt(PDIBINFO pDibInfoDst, PDIBBITS pDibBitsDst,
  50. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  51. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha,
  52. DWORD dwRop);
  53. SCODE BlitLib_FillRect(PDIBINFO pbiDst, PDIBBITS pDst,
  54. RECT * pRect, COLORREF crValue);
  55. SCODE BlitLib_WriteMaskFillRect(PDIBINFO pbiDst, PDIBBITS pDst,
  56. RECT * pRect, COLORREF crValue, DWORD dwWritemask);
  57. SCODE BlitLib_Chunk32_BitBlt08to08(PDIBINFO pDibInfoDst,
  58. PDIBBITS pDibBitsDst, PRECT prcDst, PDIBINFO pDibInfoSrc,
  59. PDIBBITS pDibBitsSrc);
  60. SCODE BlitLib_Chunk32_BitBlt08to08_Trans(PDIBINFO pDibInfoDst,
  61. PDIBBITS pDibBitsDst, PRECT prcDst, PDIBINFO pDibInfoSrc,
  62. PDIBBITS pDibBitsSrc, COLORREF crTransparent);
  63. SCODE BlitLib_PatBlt(PDIBINFO pDibInfoDst, PDIBBITS pDibBitsDst,
  64. PRECT prcDst, PDIBINFO pDibInfoPat, PDIBBITS pDibBitsPat,
  65. PRECT prcPat, COLORREF crTransparent, ALPHAREF arAlpha,
  66. DWORD dwRop);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. SCODE BlitLib_BitBlt01to01(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  71. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  72. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  73. SCODE BlitLib_BitBlt01to08(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  74. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  75. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  76. SCODE BlitLib_BitBlt01to24(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  77. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  78. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  79. SCODE BlitLib_BitBlt08to01(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  80. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  81. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  82. SCODE BlitLib_BitBlt08to08(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  83. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  84. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  85. SCODE BlitLib_BitBlt08to24(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  86. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  87. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  88. SCODE BlitLib_BitBlt08to24P(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  89. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  90. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  91. SCODE BlitLib_BitBlt08Ato24(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  92. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  93. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  94. SCODE BlitLib_BitBlt08Ato24P(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  95. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  96. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  97. SCODE BlitLib_BitBlt08Ato08A(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  98. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  99. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  100. SCODE BlitLib_BitBlt16to16(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  101. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  102. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  103. SCODE BlitLib_BitBlt16to24(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  104. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  105. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  106. SCODE BlitLib_BitBlt16to24P(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  107. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  108. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  109. SCODE BlitLib_BitBlt24to01(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  110. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  111. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  112. SCODE BlitLib_BitBlt24Pto01(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  113. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  114. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  115. SCODE BlitLib_BitBlt24to08(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  116. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  117. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  118. SCODE BlitLib_BitBlt24Pto08(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  119. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  120. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  121. SCODE BlitLib_BitBlt24to24(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  122. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  123. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  124. SCODE BlitLib_BitBlt24to24P(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  125. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  126. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  127. SCODE BlitLib_BitBlt24Ato24(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  128. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  129. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  130. SCODE BlitLib_BitBlt24Ato24P(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  131. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  132. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  133. SCODE BlitLib_BitBlt24Ato24A(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  134. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  135. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  136. SCODE BlitLib_BitBlt24Pto24P(PDIBINFO pDibInfoDest, PDIBBITS pDibBitsDest,
  137. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc,
  138. PRECT prcSrc, COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  139. SCODE BlitLib_FillRect01(PDIBINFO pbiDst, PDIBBITS pDst,
  140. int XDst, int YDst, int nWidthDst, int nHeightDst,
  141. BYTE crValue);
  142. SCODE BlitLib_FillRect08(PDIBINFO pbiDst, PDIBBITS pDst,
  143. int XDst, int YDst, int nWidthDst, int nHeightDst,
  144. BYTE crValue);
  145. SCODE BlitLib_FillRect16(PDIBINFO pbiDst, PDIBBITS pDst,
  146. int XDst, int YDst, int nWidthDst, int nHeightDst,
  147. WORD crValue);
  148. SCODE BlitLib_FillRect24(PDIBINFO pbiDst, PDIBBITS pDst,
  149. int XDst, int YDst, int nWidthDst, int nHeightDst,
  150. DWORD rgb);
  151. SCODE BlitLib_FillRect32(PDIBINFO pbiDst, PDIBBITS pDst,
  152. int XDst, int YDst, int nWidthDst, int nHeightDst,
  153. DWORD crValue);
  154. SCODE BlitLib_WriteMaskFillRect32(PDIBINFO pbiDst, PDIBBITS pDst,
  155. int XDst, int YDst, int nWidthDst, int nHeightDst,
  156. DWORD crValue, DWORD dwWriteMask);
  157. BOOL BlitLib_Detect_Intersection (PDIBBITS pdibbitsDst, PRECT prcDst,
  158. PDIBBITS pdibbitsSrc, PRECT prcSrc);
  159. SCODE BlitLib_BitBlt08to08_Intersect(PDIBINFO pDibInfoDst, PDIBBITS pDibBitsDst,
  160. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc, PRECT prcSrc,
  161. COLORREF crTransparent, DWORD dwRop);
  162. SCODE BlitLib_BitBlt16to16_Intersect(PDIBINFO pDibInfoDst, PDIBBITS pDibBitsDst,
  163. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc, PRECT prcSrc,
  164. COLORREF crTransparent, DWORD dwRop);
  165. SCODE BlitLib_BitBlt24Pto24P_Intersect(PDIBINFO pDibInfoDst, PDIBBITS pDibBitsDst,
  166. PRECT prcDst, PDIBINFO pDibInfoSrc, PDIBBITS pDibBitsSrc, PRECT prcSrc,
  167. COLORREF crTransparent, ALPHAREF arAlpha, DWORD dwRop);
  168. // function used to calculate the closest entry in an array of
  169. // COLORREFs to a given COLORREF
  170. BYTE BlitLib_PalIndexFromRGB(COLORREF crColor,COLORREF* rgcrPal,
  171. unsigned int iNumPalColors);
  172. // Based on Dib Compression type and Bit Count find a matching BPP_*
  173. WORD GetImageFormatSpecifier(DWORD dwDibComp, WORD wdBitCount);
  174. #ifndef DDRAW
  175. // BLIT_BLEND_24 -- used to alpha blend to 24bpp(packed) destinations
  176. void BlitLib_BLIT_BLEND24(COLORREF crSrc, RGBTRIPLE * ptDst,
  177. UINT alpha, UINT alphacomp);
  178. #endif
  179. // similar macros are defined in idib.hxx, be careful in changing these
  180. #define BLITLIB_RECTWIDTH(prc) ((prc)->right - (prc)->left)
  181. #define BLITLIB_RECTHEIGHT(prc) ((prc)->bottom - (prc)->top )
  182. #define BLITLIB_RECTORIGINX(prc) ((prc)->left)
  183. #define BLITLIB_RECTORIGINY(prc) ((prc)->top)
  184. #define BLITLIB_RECTORIGINPT(prc) ((POINT *)(prc))
  185. // masks that define what's stored in a DWORD-sized pixel
  186. #define RED_MASK 0x000000FF
  187. #define GREEN_MASK 0x0000FF00
  188. #define BLUE_MASK 0x00FF0000
  189. #define ALPHA_MASK 0x000000FF
  190. #define NOALPHA_MASK 0xFFFFFF00
  191. #define PERPIX_ALPHA_MASK 0xFF000000
  192. /*
  193. * PROBLEM for RGBA surfaces:
  194. * The way it used to be:
  195. #define UNUSED_MASK 0x00FFFFFF
  196. */
  197. #define UNUSED_MASK gdwUnusedBitsMask
  198. extern DWORD gdwUnusedBitsMask;
  199. // masks that define what's inside a WORD-sized pixel
  200. #define RED_MASK16 0x001F
  201. #define GREEN_MASK16 0x07E0
  202. #define BLUE_MASK16 0xF800
  203. // scottle 1bbp is not a Penguin supported format, ff must be specified in the high bytes of
  204. // both the hi & lo words.
  205. #define BLT_01TO01 0xff01ff01 // Src (hiword) = 1 Dst (loword) = 1
  206. #define BLT_01TO08 0xff010008 // Src (hiword) = 1 Dst (loword) = 8
  207. #define BLT_01TO24 0xff010220 // Src (hiword) = 1 Dst (loword) = 32 (20hex)
  208. #define BLT_08TO01 0x0008ff01 // Src (hiword) = 8 Dst (loword) = 1
  209. // andyco 24 bit dibs are actually 32 bits (888 rgb, + 8 unused). Penguin is the 0x2 preface.
  210. #define BLT_08TO08 0x00080008 // Src (hiword) = 8 Dst (loword) = 8
  211. #define BLT_08TO24 0x00080220 // Src (hiword) = 8 Dst (loword) = 32 (20hex)
  212. #define BLT_08TO24P 0x0008ff18 // Src (hiword) = 8 Dst (loword) = 24 (18hex)
  213. #define BLT_08ATO08A 0x05100510 // Src (hiword) = 16 (10hex) Dst (loword) = 16 (10hex)
  214. #define BLT_08ATO24 0x05100220 // Src (hiword) = 16 (10hex) Dst (loword) = 32 (20hex)
  215. #define BLT_08ATO24P 0x0510ff18 // Src (hiword) = 16 (10hex) Dst (loword) = 24 (18hex)
  216. #define BLT_16TO16 0x06100610 // Src (hiword) = 16 (10hex) Dst (loword) = 16 (10hex)
  217. #define BLT_16TO24 0x06100220 // Src (hiword) = 16 (10hex) Dst (loword) = 32 (20hex)
  218. #define BLT_16TO24P 0x0610ff18 // Src (hiword) = 16 (10hex) Dst (loword) = 24 (18hex)
  219. #define BLT_24TO01 0x0220ff01 // Src (hiword) = 32 (20hex) Dst (loword) = 1
  220. #define BLT_24PTO01 0xff18ff01 // Src (hiword) = 24 (18hex) Dst (loword) = 1
  221. #define BLT_24TO08 0x02200008 // Src (hiword) = 32 (20hex) Dst (loword) = 8
  222. #define BLT_24PTO08 0xff180008 // Src (hiword) = 32 (20hex) Dst (loword) = 8
  223. #define BLT_24TO24 0x02200220 // Src (hiword) = 32 (20hex) Dst (loword) = 32 (20hex)
  224. #define BLT_24TO24P 0x0220ff18 // Src (hiword) = 32 (20hex) Dst (loword) = 24 (18hex)
  225. #define BLT_24ATO24 0x03200220 // Src (hiword) = 32 (20hex) Dst (loword) = 32 (20hex)
  226. #define BLT_24ATO24P 0x0320ff18 // Src (hiword) = 32 (20hex) Dst (loword) = 24 (18hex)
  227. #define BLT_24ATO24A 0x03200320 // Src (hiword) = 32 (20hex) Dst (loword) = 32 (20hex)
  228. #define BLT_24PTO24P 0xff18ff18 // Src (hiword) = 24 (18hex) Dst (loword) = 24 (18hex)
  229. // macro used to blend src and dst together. "alpha" should range 1...256
  230. // alphacomp = 256 - alpha. Used for 24bpp
  231. #define BLIT_BLEND(src,dst,alpha,alphacomp) \
  232. (((((src) & BLUE_MASK) * (alpha) + ((dst) & BLUE_MASK) \
  233. * (alphacomp)) >> 8) & BLUE_MASK) | \
  234. (((((src) & GREEN_MASK) * (alpha) + ((dst) & GREEN_MASK) \
  235. * (alphacomp)) >> 8) & GREEN_MASK) | \
  236. (((((src) & RED_MASK) * (alpha) + ((dst) & RED_MASK) \
  237. * (alphacomp)) >> 8) & RED_MASK)
  238. #ifndef DDRAW
  239. // macro used to blend src and dst together. "alpha" should range 1...256
  240. // alphacomp = 256 - alpha. Used for 16bpp
  241. #define BLIT_BLEND16(src,dst,alpha,alphacomp) \
  242. ((WORD) ((((((DWORD) (src) & BLUE_MASK16) * (alpha) + \
  243. ((DWORD) (dst) & BLUE_MASK16) * (alphacomp)) >> 8) & BLUE_MASK16) | \
  244. (((((DWORD) (src) & GREEN_MASK16) * (alpha) + \
  245. ((DWORD) (dst) & GREEN_MASK16) * (alphacomp)) >> 8) & GREEN_MASK16) | \
  246. (((((DWORD) (src) & RED_MASK16) * (alpha) + \
  247. ((DWORD) (dst) & RED_MASK16) * (alphacomp)) >> 8) & RED_MASK16)))
  248. #endif
  249. #define BLIT_COLOR16_FROM_COLORREF(cr) \
  250. ((WORD) ((((cr) >> 8) & BLUE_MASK16) | (((cr) >> 5) & \
  251. GREEN_MASK16) | (((cr) >> 3) & RED_MASK16)))
  252. #define BLIT_COLORREF_FROM_COLOR16(w) \
  253. ((DWORD) ((((w) & BLUE_MASK16) << 8) | (((w) & GREEN_MASK16) << 5) | \
  254. (((w) & RED_MASK16) << 3)))
  255. #define MAX_POS_INT 0x7FFFFFFF
  256. #define ALPHAFROMDWORD(a) ((a & ALPHA_MASK) + 1)