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.

81 lines
2.2 KiB

  1. const ULONG MAX_DITHERTABLE_CACHE_SIZE = 4;
  2. class CDitherToRGB8 :
  3. public IImageDecodeEventSink,
  4. public IDithererImpl,
  5. public CComObjectRoot,
  6. public CComCoClass< CDitherToRGB8, &CLSID_CoDitherToRGB8 >
  7. {
  8. public:
  9. CDitherToRGB8();
  10. ~CDitherToRGB8();
  11. BEGIN_COM_MAP( CDitherToRGB8 )
  12. COM_INTERFACE_ENTRY( IImageDecodeEventSink )
  13. COM_INTERFACE_ENTRY( IDithererImpl )
  14. END_COM_MAP()
  15. DECLARE_REGISTRY( CDitherToRGB8, _T( "ImgUtil.CoDitherToRGB8.1" ),
  16. _T( "ImgUtil.CoDitherToRGB8" ), IDS_CODITHERTORGB8_DESC,
  17. THREADFLAGS_BOTH );
  18. // DECLARE_NO_REGISTRY()
  19. // IImageDecodeEventSink
  20. public:
  21. STDMETHOD( GetSurface )( LONG nWidth, LONG nHeight, REFGUID bfid,
  22. ULONG nPasses, DWORD dwHints, IUnknown** ppSurface );
  23. STDMETHOD( OnBeginDecode )( DWORD* pdwEvents, ULONG* pnFormats,
  24. GUID** ppFormats );
  25. STDMETHOD( OnBitsComplete )();
  26. STDMETHOD( OnDecodeComplete )( HRESULT hrStatus );
  27. STDMETHOD( OnPalette )();
  28. STDMETHOD( OnProgress )( RECT* pBounds, BOOL bComplete );
  29. // IDithererImpl
  30. public:
  31. STDMETHOD( SetDestColorTable )( ULONG nColors, const RGBQUAD* prgbColors );
  32. STDMETHOD( SetEventSink )( IImageDecodeEventSink* pEventSink );
  33. public:
  34. static void InitTableCache();
  35. static void CleanupTableCache();
  36. protected:
  37. HRESULT ConvertBlock( RECT* pBounds );
  38. HRESULT DitherBand( RECT* pBounds );
  39. HRESULT DitherFull();
  40. protected:
  41. static CDitherTable* s_apTableCache[MAX_DITHERTABLE_CACHE_SIZE];
  42. static ULONG s_nCacheSize;
  43. static CRITICAL_SECTION s_csCache;
  44. protected:
  45. typedef enum _ESrcFormat
  46. {
  47. RGB24,
  48. RGB8
  49. } ESrcFormat;
  50. CComPtr< IImageDecodeEventSink > m_pEventSink;
  51. CComPtr< IDirectDrawSurface > m_pDestSurface;
  52. CComPtr< IDirectDrawSurface > m_pSurface;
  53. BYTE *m_pbBits;
  54. DWORD m_dwEvents;
  55. ULONG m_nWidth;
  56. ULONG m_nHeight;
  57. ULONG m_nPitch;
  58. ULONG m_nBitsPerPixel;
  59. BOOL m_bProgressiveDither;
  60. ESrcFormat m_eSrcFormat;
  61. ULONG m_iScanLine;
  62. HBITMAP m_hbmDestDib;
  63. ERRBUF* m_pErrBuf;
  64. ERRBUF* m_pErrBuf1;
  65. ERRBUF* m_pErrBuf2;
  66. CDitherTable* m_pTable;
  67. RGBQUAD m_argbSrcColors[256];
  68. };