CeXDib.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // Class: CCeXDib
  3. //
  4. // Compiler: Visual C++
  5. // eMbedded Visual C++
  6. // Tested on: Visual C++ 6.0
  7. // Windows CE 3.0
  8. //
  9. // Author: Davide Calabro' davide_calabro@yahoo.com
  10. // http://www.softechsoftware.it
  11. //
  12. // Note: This class uses code snippets taken from a similar class written
  13. // for the Win32 enviroment by Davide Pizzolato (ing.davide.pizzolato@libero.it)
  14. //
  15. // Disclaimer
  16. // ----------
  17. // THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT
  18. // ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO REPONSIBILITIES FOR POSSIBLE
  19. // DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN. THE USER MUST ASSUME THE ENTIRE
  20. // RISK OF USING THIS SOFTWARE.
  21. //
  22. // Terms of use
  23. // ------------
  24. // THIS SOFTWARE IS FREE FOR PERSONAL USE OR FREEWARE APPLICATIONS.
  25. // IF YOU USE THIS SOFTWARE IN COMMERCIAL OR SHAREWARE APPLICATIONS YOU
  26. // ARE GENTLY ASKED TO DONATE 1$ (ONE U.S. DOLLAR) TO THE AUTHOR:
  27. //
  28. // Davide Calabro'
  29. // P.O. Box 65
  30. // 21019 Somma Lombardo (VA)
  31. // Italy
  32. //
  33. //
  34. #ifndef _CEXDIB_H_
  35. #define _CEXDIB_H_
  36. #if _MSC_VER > 1000
  37. #pragma once
  38. #endif // _MSC_VER > 1000
  39. #ifndef HDIB
  40. #define HDIB HANDLE
  41. #endif
  42. #ifndef WIDTHBYTES
  43. #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
  44. #endif
  45. #ifndef BFT_BITMAP
  46. #define BFT_BITMAP 0x4d42 // 'BM'
  47. #endif
  48. class CCeXDib
  49. {
  50. public:
  51. CCeXDib();
  52. virtual ~CCeXDib();
  53. HDIB Create(DWORD dwWidth, DWORD dwHeight, WORD wBitCount);
  54. void Clone(CCeXDib* src);
  55. void Draw(HDC hDC, DWORD dwX, DWORD dwY);
  56. LPBYTE GetBits();
  57. void Clear(BYTE byVal = 0);
  58. void SetGrayPalette();
  59. void SetPaletteIndex(BYTE byIdx, BYTE byR, BYTE byG, BYTE byB);
  60. void SetPixelIndex(DWORD dwX, DWORD dwY, BYTE byI);
  61. void BlendPalette(COLORREF crColor, DWORD dwPerc);
  62. WORD GetBitCount();
  63. DWORD GetLineWidth();
  64. DWORD GetWidth();
  65. DWORD GetHeight();
  66. WORD GetNumColors();
  67. BOOL WriteBMP(LPCTSTR bmpFileName);
  68. private:
  69. void FreeResources();
  70. DWORD GetPaletteSize();
  71. DWORD GetSize();
  72. RGBQUAD RGB2RGBQUAD(COLORREF cr);
  73. HDIB m_hDib;
  74. BITMAPINFOHEADER m_bi;
  75. DWORD m_dwLineWidth;
  76. WORD m_wColors;
  77. HBITMAP m_hBitmap; // Handle to bitmap
  78. HDC m_hMemDC; // Handle to memory DC
  79. LPVOID m_lpBits; // Pointer to actual bitmap bits
  80. };
  81. #endif