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.

990 lines
24 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: image.hxx *
  3. * *
  4. * Definitions needed for client side objects. *
  5. * *
  6. * Copyright (c) 1993-1999 Microsoft Corporation *
  7. \**************************************************************************/
  8. //
  9. // !!! temp values
  10. //
  11. extern HBITMAP hbmDefault;
  12. #define MAX_INT 0x7fffffff;
  13. #define MIN_INT 0x80000000;
  14. typedef BOOL FNTRANSBLT(
  15. HDC hdcDest,
  16. int DstX,
  17. int DstY,
  18. int DstCx,
  19. int DstCy,
  20. HDC hSrc,
  21. int SrcX,
  22. int SrcY,
  23. int SrcCx,
  24. int SrcCy,
  25. UINT Color
  26. );
  27. typedef FNTRANSBLT *PFNTRANSBLT;
  28. typedef BOOL FNTRANSDIB(
  29. HDC hdcDest,
  30. int DstX,
  31. int DstY,
  32. int DstCx,
  33. int DstCy,
  34. CONST VOID *lpBits,
  35. CONST BITMAPINFO *lpBitsInfo,
  36. UINT iUsage,
  37. int SrcX,
  38. int SrcY,
  39. int SrcCx,
  40. int SrcCy,
  41. UINT Color
  42. );
  43. typedef FNTRANSDIB *PFNTRANSDIB;
  44. typedef BOOL FNGRFILL(
  45. HDC hdc,
  46. PTRIVERTEX pVertex,
  47. ULONG nVertex,
  48. PVOID pMesh,
  49. ULONG nMesh,
  50. ULONG ulMode
  51. );
  52. typedef FNGRFILL *PFNGRFILL;
  53. typedef BOOL FNALPHABLEND(
  54. HDC hdcDest,
  55. int DstX,
  56. int DstY,
  57. int DstCx,
  58. int DstCy,
  59. HDC hSrc,
  60. int SrcX,
  61. int SrcY,
  62. int SrcCx,
  63. int SrcCy,
  64. BLENDFUNCTION BlendFunction
  65. );
  66. typedef FNALPHABLEND *PFNALPHABLEND;
  67. typedef BOOL FNALPHADIB(
  68. HDC hdcDest,
  69. int DstX,
  70. int DstY,
  71. int DstCx,
  72. int DstCy,
  73. CONST VOID *lpBits,
  74. CONST BITMAPINFO *lpBitsInfo,
  75. UINT iUsage,
  76. int SrcX,
  77. int SrcY,
  78. int SrcCx,
  79. int SrcCy,
  80. BLENDFUNCTION BlendFunction
  81. );
  82. typedef FNALPHADIB *PFNALPHADIB;
  83. //
  84. //
  85. //
  86. #define MIN(A,B) ((A) < (B) ? (A) : (B))
  87. #define MAX(A,B) ((A) > (B) ? (A) : (B))
  88. /**************************************************************************\
  89. *
  90. * rgb555,rgb565 convert r,g,b bytes to ushort
  91. *
  92. * Arguments:
  93. *
  94. *
  95. *
  96. * Return Value:
  97. *
  98. *
  99. *
  100. * History:
  101. *
  102. * 1/31/1997 Mark Enstrom [marke]
  103. *
  104. \**************************************************************************/
  105. #define rgb555(r,g,b) (((WORD)(r) << 10) | ((WORD)(g) << 5) | (WORD)(b))
  106. #define rgb565(r,g,b) (((WORD)(r) << 11) | ((WORD)(g) << 5) | (WORD)(b))
  107. extern ULONG gulDither32[];
  108. /**************************************************************************\
  109. *
  110. * TRIEDGE
  111. *
  112. * triangle mesh structure to hold all endpoint and color info
  113. *
  114. *
  115. * History:
  116. *
  117. * 2/11/1997 Mark Enstrom [marke]
  118. *
  119. \**************************************************************************/
  120. typedef struct _TRIEDGE
  121. {
  122. LONG xLeft;
  123. LONG xRight;
  124. ULONG Red;
  125. ULONG Green;
  126. ULONG Blue;
  127. ULONG Alpha;
  128. ULONG t0; // remove for retail
  129. ULONG t1; // remove for retial
  130. }TRIEDGE,*PTRIEDGE;
  131. /**************************************************************************\
  132. * TRIANGLEDATA
  133. *
  134. *
  135. * span and color gradient information for gradient fill triangles
  136. *
  137. *
  138. * History:
  139. *
  140. * 2/11/1997 Mark Enstrom [marke]
  141. *
  142. \**************************************************************************/
  143. typedef struct _TRIANGLEDATA
  144. {
  145. RECTL rcl;
  146. LONG dRdY;
  147. LONG dGdY;
  148. LONG dBdY;
  149. LONG dAdY;
  150. LONG dRdX;
  151. LONG dGdX;
  152. LONG dBdX;
  153. LONG dAdX;
  154. LONGLONG dRdXA;
  155. LONGLONG dGdXA;
  156. LONGLONG dBdXA;
  157. LONGLONG dAdXA;
  158. LONG y0;
  159. LONG y1;
  160. LONGLONG Area;
  161. POINTL ptDitherOrg;
  162. LONG DrawMode;
  163. LONG t0; // remove for retail
  164. TRIEDGE TriEdge[1];
  165. }TRIANGLEDATA,*PTRIANGLEDATA;
  166. /**************************************************************************\
  167. * GRADIENTRECTDATA
  168. *
  169. *
  170. * color gradient information for gradient fill rectangles
  171. *
  172. *
  173. * History:
  174. *
  175. * 2/11/1997 Mark Enstrom [marke]
  176. *
  177. \**************************************************************************/
  178. typedef struct _GRADIENTRECTDATA
  179. {
  180. RECTL rclClip;
  181. RECTL rclGradient;
  182. POINTL ptDraw;
  183. SIZEL szDraw;
  184. ULONG Red;
  185. ULONG Green;
  186. ULONG Blue;
  187. ULONG Alpha;
  188. LONG dRdY;
  189. LONG dGdY;
  190. LONG dBdY;
  191. LONG dAdY;
  192. LONG dRdX;
  193. LONG dGdX;
  194. LONG dBdX;
  195. LONG dAdX;
  196. POINTL ptDitherOrg;
  197. ULONG ulMode;
  198. LONG xScanAdjust;
  199. LONG yScanAdjust;
  200. }GRADIENTRECTDATA,*PGRADIENTRECTDATA;
  201. /**************************************************************************\
  202. *
  203. * TRIDDA
  204. *
  205. * Triangle DDA information for calculating and running line dda
  206. *
  207. * History:
  208. *
  209. * 2/11/1997 Mark Enstrom [marke]
  210. *
  211. \**************************************************************************/
  212. typedef struct _TRIDDA
  213. {
  214. LONG dN; // Delta Y
  215. LONG dM; // Delta X
  216. LONG M0; // Initial X Device space
  217. LONG N0; // Initial Y Device spave
  218. LONGLONG C; // Initial Error Constant
  219. LONG dL; // Interger component of delta X
  220. LONG dR; // Remainder component of delta X
  221. LONG R; // Remainder
  222. LONG Rb; // Remainder used to compare with 0
  223. LONG L; // Temp
  224. LONG j; // Temp
  225. LONG Linc; // X inc (pos or neg)
  226. LONG yIndex; // Current index into line array
  227. LONG NumScanLines; // Number of scan lines to run
  228. LONG Red; // Current Color
  229. LONG Green; // Current Color
  230. LONG Blue; // Current Color
  231. LONG Alpha; // Current Color
  232. LONG dxyRed; // Combined integer change for step in x and y
  233. LONG dxyGreen; // Combined integer change for step in x and y
  234. LONG dxyBlue; // Combined integer change for step in x and y
  235. LONG dxyAlpha; // Combined integer change for step in x and y
  236. LONG dxLRed; // Fraction change in color for step in x
  237. LONG dxLGreen; // Fraction change in color for step in x
  238. LONG dxLBlue; // Fraction change in color for step in x
  239. LONG dxLAlpha; // Fraction change in color for step in x
  240. }TRIDDA,*PTRIDDA;
  241. #if DBG
  242. extern ULONG DbgRecord;
  243. #endif
  244. VOID
  245. ImgFillMemoryULONG(
  246. PBYTE pDst,
  247. ULONG ulPat,
  248. ULONG cxBytes
  249. );
  250. VOID Dprintf( LPSTR szFmt, ... );
  251. inline
  252. VOID
  253. vHorizontalLine(
  254. PTRIVERTEX pv1,
  255. PTRIVERTEX pv2,
  256. PTRIANGLEDATA ptData,
  257. PTRIDDA ptridda
  258. );
  259. VOID
  260. vLeftEdgeDDA(
  261. PTRIANGLEDATA ptData,
  262. PTRIDDA ptridda
  263. );
  264. VOID
  265. vRightEdgeDDA(
  266. PTRIANGLEDATA ptData,
  267. PTRIDDA ptridda
  268. );
  269. BOOL
  270. bGetRectRegionFromDC(
  271. HDC hdc,
  272. PRECTL prclClip
  273. );
  274. //
  275. // Alpha Blending
  276. //
  277. //
  278. //
  279. typedef struct _PIXEL32
  280. {
  281. BYTE b;
  282. BYTE g;
  283. BYTE r;
  284. BYTE a;
  285. }PIXEL32,*PPIXEL32;
  286. typedef union _ALPHAPIX
  287. {
  288. PIXEL32 pix;
  289. RGBQUAD rgb;
  290. ULONG ul;
  291. } ALPHAPIX,*PALPHAPIX;
  292. typedef union _PAL_ULONG
  293. {
  294. PALETTEENTRY pal;
  295. ULONG ul;
  296. } PAL_ULONG;
  297. extern ALPHAPIX aPalHalftone[256];
  298. extern BYTE gHalftoneColorXlate332[];
  299. BOOL
  300. bIsHalftonePalette(ULONG *pPalette);
  301. #define XPAL_BGRA 0x00000001
  302. #define XPAL_RGB32 0x00000002
  303. #define XPAL_BGR32 0x00000004
  304. #define XPAL_RGB24 0x00000008
  305. #define XPAL_RGB16_565 0x00000010
  306. #define XPAL_RGB16_555 0x00000020
  307. #define XPAL_HALFTONE 0x00000040
  308. #define XPAL_1PAL 0x00000080
  309. #define XPAL_4PAL 0x00000100
  310. #define XPAL_8PAL 0x00000200
  311. #define XPAL_BITFIELDS 0x00000400
  312. /**************************************************************************\
  313. *
  314. * structure PALINFO
  315. *
  316. * Arguments:
  317. *
  318. *
  319. *
  320. * Return Value:
  321. *
  322. *
  323. *
  324. * History:
  325. *
  326. * 12/10/1996 Mark Enstrom [marke]
  327. *
  328. \**************************************************************************/
  329. typedef struct _PALINFO
  330. {
  331. PBITMAPINFO pBitmapInfo;
  332. PBYTE pxlate332;
  333. ULONG flPal;
  334. }PALINFO,*PPALINFO;
  335. //
  336. // alpha blending call data
  337. //
  338. VOID
  339. vPixelBlendOrDissolveOver(
  340. ALPHAPIX *ppixDst,
  341. ALPHAPIX *ppixSrc,
  342. LONG cx,
  343. BLENDFUNCTION BlendFunction,
  344. PBYTE pwrMask
  345. );
  346. VOID
  347. vPixelBlend(
  348. ALPHAPIX *ppixDst,
  349. ALPHAPIX *ppixSrc,
  350. LONG cx,
  351. BLENDFUNCTION BlendFunction,
  352. PBYTE pwrMask
  353. );
  354. VOID
  355. vPixelBlend16_555(
  356. ALPHAPIX *ppixDst,
  357. ALPHAPIX *ppixSrc,
  358. LONG cx,
  359. BLENDFUNCTION BlendFunction,
  360. PBYTE pwrMask
  361. );
  362. VOID
  363. vPixelBlend16_565(
  364. ALPHAPIX *ppixDst,
  365. ALPHAPIX *ppixSrc,
  366. LONG cx,
  367. BLENDFUNCTION BlendFunction,
  368. PBYTE pwrMask
  369. );
  370. VOID
  371. vPixelOver(
  372. ALPHAPIX *ppixDst,
  373. ALPHAPIX *ppixSrc,
  374. LONG cx,
  375. BLENDFUNCTION BlendFunction,
  376. PBYTE pwrMask
  377. );
  378. VOID
  379. vPixelGeneralBlend(
  380. ALPHAPIX *ppixDst,
  381. ALPHAPIX *ppixSrc,
  382. LONG cx,
  383. BLENDFUNCTION BlendFunction,
  384. PBYTE pWriteMask
  385. );
  386. VOID
  387. mmxPixelOver(
  388. ALPHAPIX *pDst,
  389. ALPHAPIX *pSrc,
  390. LONG Width,
  391. BLENDFUNCTION BlendFunction,
  392. PBYTE pwrMask);
  393. VOID
  394. mmxPixelBlendOrDissolveOver(
  395. ALPHAPIX *pDst,
  396. ALPHAPIX *pSrc,
  397. LONG Width,
  398. BLENDFUNCTION BlendFunction,
  399. PBYTE pwrMask
  400. );
  401. BOOL
  402. bIsMMXProcessor(VOID);
  403. typedef VOID (*PFN_GENERALBLEND)(PALPHAPIX,PALPHAPIX,LONG,BLENDFUNCTION,PBYTE);
  404. typedef VOID (*PFN_PIXLOAD_AND_CONVERT)(PULONG,PBYTE,LONG,LONG,PVOID);
  405. typedef VOID (*PFN_PIXCONVERT_AND_STORE)(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  406. typedef struct _ALPHA_DISPATCH_FORMAT
  407. {
  408. ULONG ulDstBitsPerPixel;
  409. ULONG ulSrcBitsPerPixel;
  410. PFN_PIXLOAD_AND_CONVERT pfnLoadSrcAndConvert;
  411. PFN_PIXLOAD_AND_CONVERT pfnLoadDstAndConvert;
  412. PFN_PIXCONVERT_AND_STORE pfnConvertAndStore;
  413. PFN_GENERALBLEND pfnGeneralBlend;
  414. BLENDFUNCTION BlendFunction;
  415. BOOL bUseMMX;
  416. }ALPHA_DISPATCH_FORMAT,*PALPHA_DISPATCH_FORMAT;
  417. BOOL
  418. AlphaScanLineBlend(
  419. PBYTE pDst,
  420. PRECTL pDstRect,
  421. ULONG DeltaDst,
  422. PBYTE pSrc,
  423. ULONG DeltaSrc,
  424. PPOINTL pptlSrc,
  425. PPALINFO ppalInfoDst,
  426. PPALINFO ppalInfoSrc,
  427. PALPHA_DISPATCH_FORMAT pAlphaDispatch
  428. );
  429. //
  430. // palinfo routines
  431. //
  432. BOOL inline bIsBGRA(ULONG flPal) { return (flPal & XPAL_BGRA);}
  433. BOOL inline bIsRGB32(ULONG flPal) { return (flPal & XPAL_RGB32);}
  434. BOOL inline bIsBGR32(ULONG flPal) { return (flPal & XPAL_BGR32);}
  435. BOOL inline bIsRGB24(ULONG flPal) { return (flPal & XPAL_RGB24);}
  436. BOOL inline bIsRGB16_565(ULONG flPal) { return (flPal & XPAL_RGB16_565);}
  437. BOOL inline bIsRGB16_555(ULONG flPal) { return (flPal & XPAL_RGB16_555);}
  438. BOOL inline bIsHalftone(ULONG flPal) { return (flPal & XPAL_HALFTONE);}
  439. ULONG inline flRed(PPALINFO ppalInfo)
  440. {
  441. if (ppalInfo->pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS)
  442. {
  443. ALPHAPIX pix;
  444. pix.rgb = ppalInfo->pBitmapInfo->bmiColors[0];
  445. return(pix.ul);
  446. }
  447. return(0);
  448. }
  449. ULONG inline flGreen(PPALINFO ppalInfo)
  450. {
  451. if (ppalInfo->pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS)
  452. {
  453. ALPHAPIX pix;
  454. pix.rgb = ppalInfo->pBitmapInfo->bmiColors[1];
  455. return(pix.ul);
  456. }
  457. return(0);
  458. }
  459. ULONG inline flBlue(PPALINFO ppalInfo)
  460. {
  461. if (ppalInfo->pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS)
  462. {
  463. ALPHAPIX pix;
  464. pix.rgb = ppalInfo->pBitmapInfo->bmiColors[2];
  465. return(pix.ul);
  466. }
  467. return(0);
  468. }
  469. VOID vLoadAndConvert1ToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  470. VOID vLoadAndConvert4ToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  471. VOID vLoadAndConvert8ToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  472. VOID vLoadAndConvertRGB16_555ToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  473. VOID vLoadAndConvertRGB16_565ToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  474. VOID vLoadAndConvert16BitfieldsToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  475. VOID vLoadAndConvertRGB24ToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  476. VOID vLoadAndConvertRGB32ToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  477. VOID vLoadAndConvert32BitfieldsToBGRA(PULONG,PBYTE,LONG,LONG,PVOID);
  478. VOID vConvertAndSaveBGRATo1(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  479. VOID vConvertAndSaveBGRAToRGB32(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  480. VOID vConvertAndSaveBGRATo32Bitfields(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  481. VOID vConvertAndSaveBGRAToRGB24(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  482. VOID vConvertAndSaveBGRATo16Bitfields(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  483. VOID vConvertAndSaveBGRAToRGB16_565(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  484. VOID vConvertAndSaveBGRAToRGB16_555(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  485. VOID vConvertAndSaveBGRATo8(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  486. VOID vConvertAndSaveBGRATo4(PBYTE,PULONG,LONG,LONG,PVOID,PBYTE);
  487. BOOL bInitializePALINFO(PPALINFO);
  488. VOID vCleanupPALINFO(PPALINFO);
  489. /**************************************************************************\
  490. * DIBINFO
  491. *
  492. * keep track of temp DIB information
  493. *
  494. * elements:
  495. *
  496. *
  497. * History:
  498. *
  499. *
  500. \**************************************************************************/
  501. typedef struct _DIBINFO
  502. {
  503. HDC hdc; // hdc handle
  504. HBITMAP hDIB; // bitmap handle if a temp DIBsection is used
  505. RECTL rclBounds; // API bounding rect in device space
  506. RECTL rclBoundsTrim; // API bounding rect trimmed to DIB
  507. RECTL rclClipDC; // clip rect associated with input DC
  508. RECTL rclDIB; // DIB boundary in device space, drawing is done to this
  509. POINTL ptlGradOffset; // offset to apply to all GradientFill coords
  510. PBITMAPINFO pbmi; // pointer to bitmapinfo struct of the DIBsection
  511. PVOID pvBits; // pointer to the bit values
  512. PVOID pvBase; // starting point of the bits (pvScan0)
  513. LONG stride; // number of bytes to the next scan
  514. UINT iUsage; // DIB_RGB_COLORS or DIB_PAL_COLORS
  515. PBYTE pxlate332; // RGB332 to surface xlate for palette surfaces
  516. ULONG flag; // misc flags
  517. } DIBINFO, *PDIBINFO;
  518. #define SOURCE_TRAN 0
  519. #define SOURCE_ALPHA 1
  520. #define SOURCE_GRADIENT_RECT 2
  521. #define SOURCE_GRADIENT_TRI 3
  522. VOID vCopyBitmapInfo (
  523. PBITMAPINFO pbmiTo,
  524. PBITMAPINFO pbmiFrom
  525. );
  526. BOOL GetCompatibleDIBInfo(
  527. HBITMAP hbm,
  528. PVOID *ppvBase,
  529. LONG *plStride);
  530. BOOL bSameDIBformat (
  531. PBITMAPINFO pbmiDst,
  532. PBITMAPINFO pbmiSrc
  533. );
  534. BOOL bSetupBitmapInfos(
  535. PDIBINFO pDibInfoDst,
  536. PDIBINFO pDibInfoSrc
  537. );
  538. BOOL
  539. bDIBGetSrcDIBits (
  540. PDIBINFO pDibInfoDst,
  541. PDIBINFO pDibInfoSrc,
  542. FLONG flSourceMode,
  543. ULONG TransColor
  544. );
  545. BOOL
  546. bDIBInitDIBINFO (
  547. PBITMAPINFO p,
  548. CONST VOID * pvBits,
  549. int x,
  550. int y,
  551. int cx,
  552. int cy,
  553. PDIBINFO pDibInfo
  554. );
  555. BOOL
  556. bGetSrcDIBits(
  557. PDIBINFO pDibInfoDst,
  558. PDIBINFO pDibInfoSrc,
  559. FLONG flCopyMode,
  560. ULONG TranColor
  561. );
  562. BOOL
  563. bInitDIBINFO(
  564. HDC hdc,
  565. int x,
  566. int y,
  567. int cx,
  568. int cy,
  569. PDIBINFO pDibInfo
  570. );
  571. BOOL
  572. bSendDIBINFO(
  573. HDC hdcDst,
  574. PDIBINFO pDibInfo
  575. );
  576. VOID
  577. vCleanupDIBINFO(
  578. PDIBINFO pDibInfo
  579. );
  580. BOOL
  581. bGetDstDIBits(
  582. PDIBINFO pDibInfo,
  583. BOOL *pbReadable,
  584. FLONG flCopyMode
  585. );
  586. //
  587. // gradient fill
  588. //
  589. /**************************************************************************\
  590. * GRAD_PALETTE_MATCH
  591. *
  592. *
  593. * Arguments:
  594. *
  595. * palIndex - return palette index
  596. * pxlate - rgb332 to palette index table
  597. * r,g,b - byte colors
  598. *
  599. * Return Value:
  600. *
  601. *
  602. *
  603. * History:
  604. *
  605. * 3/3/1997 Mark Enstrom [marke]
  606. *
  607. \**************************************************************************/
  608. #define GRAD_PALETTE_MATCH(palIndex,pxlate,r,g,b) \
  609. \
  610. palIndex = pxlate[((r & 0xe0)) | \
  611. ((g & 0xe0) >> 3) | \
  612. ((b & 0xc0) >> 6)]; \
  613. \
  614. /**************************************************************************\
  615. *
  616. * Dither information for 8bpp. This is customized for dithering to
  617. * the halftone palette [6,6,6] color cube, and default palette.
  618. *
  619. * History:
  620. *
  621. * 2/24/1997 Mark Enstrom [marke]
  622. *
  623. \**************************************************************************/
  624. #define DITHER_8_MASK_Y 0x0F
  625. #define DITHER_8_MASK_X 0x0F
  626. extern BYTE gDitherMatrix16x16Halftone[];
  627. extern BYTE gDitherMatrix16x16Default[];
  628. extern BYTE HalftoneSaturationTable[];
  629. extern BYTE DefaultSaturationTable[];
  630. #define SWAP_VERTEX(pv0,pv1,pvt) \
  631. { \
  632. pvt = pv0; \
  633. pv0 = pv1; \
  634. pv1 = pvt; \
  635. }
  636. BOOL
  637. bCalculateTriangle(
  638. PTRIVERTEX pv0,
  639. PTRIVERTEX pv1,
  640. PTRIVERTEX pv2,
  641. PTRIANGLEDATA ptData
  642. );
  643. VOID
  644. vFillTriDIB1(
  645. PDIBINFO pDibInfo,
  646. HDC hdc,
  647. PTRIANGLEDATA ptData
  648. );
  649. VOID
  650. vFillTriDIB4(
  651. PDIBINFO pDibInfo,
  652. HDC hdc,
  653. PTRIANGLEDATA ptData
  654. );
  655. VOID
  656. vFillTriDIB8(
  657. PDIBINFO pDibInfo,
  658. HDC hdc,
  659. PTRIANGLEDATA ptData
  660. );
  661. VOID
  662. vFillTriDIB16_565(
  663. PDIBINFO pDibInfo,
  664. HDC hdc,
  665. PTRIANGLEDATA ptData
  666. );
  667. VOID
  668. vFillTriDIB16_555(
  669. PDIBINFO pDibInfo,
  670. HDC hdc,
  671. PTRIANGLEDATA ptData
  672. );
  673. VOID
  674. vFillTriDIB32RGB(
  675. PDIBINFO pDibInfo,
  676. HDC hdc,
  677. PTRIANGLEDATA ptData
  678. );
  679. VOID
  680. vFillTriDIB32BGRA(
  681. PDIBINFO pDibInfo,
  682. HDC hdc,
  683. PTRIANGLEDATA ptData
  684. );
  685. VOID
  686. vFillTriDIB24RGB(
  687. PDIBINFO pDibInfo,
  688. HDC hdc,
  689. PTRIANGLEDATA ptData
  690. );
  691. typedef VOID (*PFN_TRIFILL)(PDIBINFO,PTRIANGLEDATA);
  692. typedef VOID (*PFN_GRADRECT)(PDIBINFO,PGRADIENTRECTDATA);
  693. PFN_TRIFILL
  694. pfnTriangleFillFunction(
  695. PDIBINFO pDibInfo,
  696. BOOL bUnreadable
  697. );
  698. PFN_GRADRECT
  699. pfnGradientRectFillFunction(
  700. PDIBINFO pDibInfo
  701. );
  702. //
  703. // gradient fill rect
  704. //
  705. BOOL
  706. DIBGradientRect(
  707. HDC hdc,
  708. PTRIVERTEX pVertex,
  709. ULONG nVertex,
  710. PGRADIENT_RECT pMesh,
  711. ULONG nMesh,
  712. ULONG ulMode,
  713. PRECTL prclPhysExt,
  714. PDIBINFO pDibInfo,
  715. PPOINTL pptlDitherOrg
  716. );
  717. //
  718. // alpha
  719. //
  720. BOOL
  721. bInitAlpha();
  722. extern PBYTE pAlphaMulTable;
  723. #define INT_MULT(a,b,t) \
  724. t = ((a)*(b)) + 0x80; \
  725. t = ((((t) >> 8) + t) >> 8);
  726. #define INT_LERP(a,s,d,t) \
  727. INT_MULT((a),((s)-(d)),t); \
  728. t = t + (d);
  729. #define INT_PRELERP(a,s,d,t) \
  730. INT_MULT((a),(d),t); \
  731. t = (s) + (d) - t;
  732. #if DBG
  733. extern ULONG DbgAlpha;
  734. #define ALPHAMSG(level,s) \
  735. if (DbgAlpha >= level) \
  736. { \
  737. DbgPrint("%s\n",s); \
  738. }
  739. #else
  740. #define ALPHAMSG(level,s)
  741. #endif
  742. //
  743. //
  744. // routines to create compatible DIB/DC
  745. //
  746. //
  747. static
  748. UINT
  749. MyGetSystemPaletteEntries(HDC hdc, UINT iStartIndex, UINT nEntries,LPPALETTEENTRY lppe);
  750. static
  751. BOOL
  752. bFillColorTable(HDC hdc, HPALETTE hpal, BITMAPINFO *pbmi);
  753. static BOOL
  754. bFillColorTable(HDC hdc, HPALETTE hpal, BITMAPINFO *pbmi);
  755. static BOOL
  756. bFillBitmapInfoDirect(HDC hdc, HPALETTE hpal, BITMAPINFO *pbmi);
  757. static BOOL
  758. bFillBitmapInfoMemory(HDC hdc, HPALETTE hpal, BITMAPINFO *pbmi);
  759. HBITMAP APIENTRY
  760. CreateCompatibleDIB(
  761. HDC hdc,
  762. ULONG ulWidth,
  763. ULONG ulHeight,
  764. PVOID *ppvBits,
  765. BITMAPINFO *pbmi);
  766. VOID CreateTempDIBSections (HDC,HDC,ULONG,ULONG,PVOID *,PVOID *,HBITMAP *,HBITMAP *,PBITMAPINFO);
  767. BOOL
  768. WinAlphaBlend(
  769. HDC hdcDst,
  770. int DstX,
  771. int DstY,
  772. int DstCx,
  773. int DstCy,
  774. HDC hdcSrc,
  775. int SrcX,
  776. int SrcY,
  777. int SrcCx,
  778. int SrcCy,
  779. BLENDFUNCTION BlendFunction
  780. );
  781. BOOL
  782. WinAlphaDIBBlend(
  783. HDC hdcDst,
  784. int DstX,
  785. int DstY,
  786. int DstCx,
  787. int DstCy,
  788. CONST VOID *lpBits,
  789. CONST BITMAPINFO *lpBitsInfo,
  790. UINT iUsage,
  791. int SrcX,
  792. int SrcY,
  793. int SrcCx,
  794. int SrcCy,
  795. BLENDFUNCTION BlendFunction
  796. );
  797. BOOL
  798. WinGradientFill(
  799. HDC hdc,
  800. PTRIVERTEX pLogVertex,
  801. ULONG nVertex,
  802. PVOID pMesh,
  803. ULONG nMesh,
  804. ULONG ulMode
  805. );
  806. BOOL
  807. WinTransparentDIBits(
  808. HDC hdcDst,
  809. int xDst,
  810. int yDst,
  811. int cxDst,
  812. int cyDst,
  813. CONST VOID * lpBits,
  814. CONST BITMAPINFO *lpBitsInfo,
  815. UINT iUsage,
  816. int xSrc,
  817. int ySrc,
  818. int cxSrc,
  819. int cySrc,
  820. UINT TransColor
  821. );
  822. BOOL
  823. WinTransparentBlt(
  824. HDC hdcDst,
  825. int xDst,
  826. int yDst,
  827. int cxDst,
  828. int cyDst,
  829. HDC hdcSrc,
  830. int xSrc,
  831. int ySrc,
  832. int cxSrc,
  833. int cySrc,
  834. UINT TransColor
  835. );
  836. PBYTE
  837. pGenColorXform332(
  838. PULONG ppalIn,
  839. ULONG ulNumEntries
  840. );
  841. //
  842. // memory allocation
  843. //
  844. #if !(_WIN32_WINNT >= 0x500)
  845. #define LOCALALLOC(size) LocalAlloc(LMEM_FIXED,size)
  846. #define LOCALFREE(pv) LocalFree(pv)
  847. #else
  848. #define LOCALALLOC(size) RtlAllocateHeap(RtlProcessHeap(),0,size)
  849. #define LOCALFREE(pv) (void)RtlFreeHeap(RtlProcessHeap(),0,pv)
  850. #endif
  851.