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.

83 lines
3.0 KiB

  1. #ifndef _DITHERS_H
  2. #define _DITHERS_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. ///////////////////////////////////////////////////////////////////////////////
  7. //
  8. // Dithering stuff.
  9. //
  10. // This code implements error-diffusion to an arbitrary set of colors,
  11. // optionally with transparency. Since the output colors can be arbitrary,
  12. // the color picker for the dither is a 32k inverse-mapping table. 24bpp
  13. // values are whacked down to 16bpp (555) and used as indices into the table.
  14. // To compensate for posterization effects when converting 24bpp to 16bpp, an
  15. // ordered dither (16bpp halftone) is used to generate the 555 color.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. typedef struct
  19. {
  20. int r, g, b;
  21. } ERRBUF;
  22. __inline size_t ErrbufBytes(size_t pels)
  23. {
  24. return (pels + 2) * sizeof(ERRBUF);
  25. }
  26. ///////////////////////////////////////////////////////////////////////////////
  27. void Dith8to8(BYTE *dst, const BYTE *src, int dst_next_scan, int src_next_scan,
  28. const RGBQUAD *colorsIN, const RGBQUAD *colorsOUT, const BYTE *map,
  29. ERRBUF *cur_err, ERRBUF *nxt_err, UINT x, UINT cx, UINT y, int cy);
  30. void Convert8to8( BYTE* pbDest, const BYTE* pbSrc, int nDestPitch,
  31. int nSrcPitch, const RGBQUAD* prgbColors, const BYTE* pbMap, UINT x,
  32. UINT nWidth, UINT y, int nHeight );
  33. void DithGray8to8( BYTE* pbDest, const BYTE* pbSrc, int nDestPitch,
  34. int nSrcPitch, const RGBQUAD* prgbColors, const BYTE* pbMap,
  35. ERRBUF* pCurrentError, ERRBUF* pNextError, UINT x, UINT cx, UINT y,
  36. int cy );
  37. void ConvertGray8to8( BYTE* pbDest, const BYTE* pbSrc, int nDestPitch,
  38. int nSrcPitch, const BYTE* pbMap, UINT x, UINT nWidth, UINT y,
  39. int nHeight );
  40. void Dith8to8t(BYTE *dst, const BYTE *src, int dst_next_scan,
  41. int src_next_scan, const RGBQUAD *colorsIN, const RGBQUAD *colorsOUT,
  42. const BYTE *map, ERRBUF *cur_err, ERRBUF *nxt_err, UINT x, UINT cx, UINT y,
  43. int cy, BYTE indexTxpOUT, BYTE indexTxpIN);
  44. void Dith8to16(WORD *dst, const BYTE *src, int dst_next_scan,
  45. int src_next_scan, const RGBQUAD *colors, ERRBUF *cur_err, ERRBUF *nxt_err,
  46. UINT x, UINT cx, UINT y, int cy);
  47. void Dith8to16t(WORD *dst, const BYTE *src, int dst_next_scan,
  48. int src_next_scan, const RGBQUAD *colors, ERRBUF *cur_err, ERRBUF *nxt_err,
  49. UINT x, UINT cx, UINT y, int cy, WORD wColorTxpOUT, BYTE indexTxpIN);
  50. void Dith24to8(BYTE *dst, const BYTE *src, int dst_next_scan,
  51. int src_next_scan, const RGBQUAD *colors, const BYTE *map, ERRBUF *cur_err,
  52. ERRBUF *nxt_err, UINT x, UINT cx, UINT y, int cy);
  53. void Convert24to8( BYTE* pbDest, const BYTE* pbSrc, int nDestPitch,
  54. int nSrcPitch, const BYTE* pbMap, UINT x, UINT nWidth, UINT y,
  55. int nHeight );
  56. void Dith24to16(WORD *dst, const BYTE *src, int dst_next_scan,
  57. int src_next_scan, ERRBUF *cur_err, ERRBUF *nxt_err, UINT x, UINT cx,
  58. UINT y, int cy);
  59. ///////////////////////////////////////////////////////////////////////////////
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif // _DITHERS_H