Source code of Windows XP (NT5)
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.

124 lines
3.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1997 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // Bitmap.h
  7. //
  8. // Abstract:
  9. // Definition of the CMyBitmap class.
  10. //
  11. // Implementation File:
  12. // Bitmap.cpp
  13. //
  14. // Author:
  15. // David Potter (davidp) June 12, 1996
  16. //
  17. // Revision History:
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #ifndef _BITMAP_H_
  21. #define _BITMAP_H_
  22. /////////////////////////////////////////////////////////////////////////////
  23. // Forward Class Declarations
  24. /////////////////////////////////////////////////////////////////////////////
  25. class CMyBitmap;
  26. /////////////////////////////////////////////////////////////////////////////
  27. // Type Definitions
  28. /////////////////////////////////////////////////////////////////////////////
  29. #define nMaxSavedSystemPaletteEntries 256
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CMyBitmap
  32. /////////////////////////////////////////////////////////////////////////////
  33. class CMyBitmap
  34. {
  35. public:
  36. // static int s_rgnColorWindowNormal[16];
  37. // static int s_rgnColorWindowHighlighted[16];
  38. // static int s_rgnColorButtonNormal[16];
  39. // static int s_rgnColorButtonHighlighted[16];
  40. static PALETTEENTRY s_rgpeSavedSystemPalette[];
  41. int m_nSavedSystemPalette;
  42. private:
  43. HINSTANCE m_hinst;
  44. BITMAPINFO * m_pbiNormal;
  45. BITMAPINFO * m_pbiHighlighted;
  46. BYTE * m_pbBitmap;
  47. int m_dx;
  48. int m_dy;
  49. int m_nColors;
  50. CB m_cbColorTable;
  51. CB m_cbBitmapInfo;
  52. CB m_cbImageSize;
  53. HPALETTE m_hPalette;
  54. BOOL m_bCustomPalette;
  55. protected:
  56. HINSTANCE Hinst(void) const { return m_hinst; }
  57. BITMAPINFO * PbiNormal(void) const { return m_pbiNormal;}
  58. BITMAPINFO * PbiHighlighted(void) const { return m_pbiHighlighted; }
  59. BYTE * PbBitmap(void) const { return m_pbBitmap; }
  60. void LoadColors(int * pnColor, BITMAPINFO * pbi);
  61. int NColorsFromBitCount(int nBitCount) const;
  62. CB CbColorTable(void) const { return m_cbColorTable; }
  63. CB CbBitmapInfo(void) const { return m_cbBitmapInfo; }
  64. CB CbImageSize(void) const { return m_cbImageSize; }
  65. HPALETTE HPalette(void) const { return m_hPalette; }
  66. BOOL BCustomPalette(void) const { return m_bCustomPalette; }
  67. void LoadBitmapResource(ID idBitmap, HINSTANCE hinst, LANGID langid);
  68. void SaveSystemPalette(void);
  69. void CreatePalette(void);
  70. void CreatePALColorMapping(void);
  71. public:
  72. CMyBitmap(void);
  73. virtual ~CMyBitmap(void);
  74. int Dx(void) const { return m_dx; }
  75. int Dy(void) const { return m_dy; }
  76. int NColors(void) const { return m_nColors; }
  77. void SetHinst(HINSTANCE hinst) { ASSERT(hinst != NULL); m_hinst = hinst; }
  78. void SetCustomPalette(BOOL bCustomPalette) { m_bCustomPalette = bCustomPalette; }
  79. void Load(ID idBitmap);
  80. virtual void Paint(HDC hdc, RECT * prc, BOOL bSelected);
  81. void LoadColors(int * pnColorNormal, int * pnColorHighlighted);
  82. void LoadColors(int * pnColorNormal);
  83. RGBQUAD RgbQuadColorNormal(int nColor) const
  84. {
  85. ASSERT(nColor >= 0 && nColor < NColors());
  86. return PbiNormal()->bmiColors[nColor];
  87. }
  88. void SetRgbQuadColorNormal(RGBQUAD rgbQuad, int nColor)
  89. {
  90. ASSERT(nColor >= 0 && nColor < NColors());
  91. PbiNormal()->bmiColors[nColor] = rgbQuad;
  92. }
  93. }; //*** class CMyBitmap
  94. /////////////////////////////////////////////////////////////////////////////
  95. #endif // _BITMAP_H_