ImageEx.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef IMAGE_HEAD_FILE
  2. #define IMAGE_HEAD_FILE
  3. #pragma once
  4. #include "SkinUI.h"
  5. //////////////////////////////////////////////////////////////////////////////////
  6. struct IMAGEPARAMENT
  7. {
  8. int nWidth;
  9. int nHeight;
  10. int nBitCount;
  11. int nBytesPerLine;
  12. int nBytesPerPixel;
  13. int nNumColors;
  14. int nSize;
  15. };
  16. //图片对象
  17. class SKINUI_CLASS CImageEx: public CImage
  18. {
  19. //变量定义
  20. protected:
  21. RECT m_rcNinePart;
  22. CImage m_ImageClone;
  23. BYTE m_cbAlpha;
  24. //函数定义
  25. public:
  26. //构造函数
  27. CImageEx();
  28. //析构函数
  29. virtual ~CImageEx();
  30. //设置函数
  31. public:
  32. //九宫格绘图
  33. void SetNinePart(CONST LPRECT lprcNinePart);
  34. //Alpha处理
  35. bool SetAlphaBit();
  36. //转HBITMAP
  37. HBITMAP ImageToBitmap();
  38. //灰度处理
  39. bool SetGray();
  40. //
  41. inline void SetAlpha(BYTE cbAlpha){ m_cbAlpha = cbAlpha; }
  42. void SetRotation(int nAngle);
  43. //管理函数
  44. public:
  45. //销毁图片
  46. bool DestroyImage();
  47. //加载图片
  48. bool LoadImage(LPCTSTR pszFileName);
  49. //加载图片
  50. bool LoadImage(HINSTANCE hInstance, LPCTSTR pszResourceName,LPCTSTR pszResourceType=TEXT("IMAGE"));
  51. //绘画函数
  52. public:
  53. //绘画图像
  54. BOOL DrawImage(CDC * pDC, INT nXPos, INT nYPos);
  55. //绘画图像
  56. BOOL DrawImage(CDC * pDC, INT nXPos, INT nYPos, INT nDestWidth, INT nDestHeight);
  57. //绘画图像
  58. BOOL DrawImage(CDC * pDC, RECT &rc);
  59. //绘画图像
  60. BOOL DrawImage(CDC * pDC, INT nXDest, INT nYDest, INT nDestWidth, INT nDestHeight, INT nXScr, INT nYSrc);
  61. //绘画图像
  62. BOOL DrawImage(CDC * pDC, INT nXDest, INT nYDest, INT nDestWidth, INT nDestHeight, INT nXScr, INT nYSrc, INT nSrcWidth, INT nSrcHeight);
  63. //区域绘制
  64. public:
  65. //绘画图像
  66. bool Draw( CDC * pDC, INT x, INT y, INT cx, INT cy,INT nLeft,INT nTop,INT nRight,INT nBottom );
  67. //绘画图像
  68. bool Draw( CDC * pDC, const RECT& rectDest, const RECT& rectSrc );
  69. //绘画图像
  70. bool Draw( CDC * pDC, const RECT& rectDest );
  71. //绘画图像
  72. bool DrawFrame( CDC * pDC, const RECT& rectDest );
  73. //拉伸绘制
  74. public:
  75. //
  76. bool DrawExtrude(CDC*pDC,const RECT& rectDest,bool bLeft=false,int nPixel=1);
  77. protected:
  78. //
  79. void GetImageParament(CImage *pImg,IMAGEPARAMENT *ppImgParam);
  80. int InImage(CImage *pImg,int x,int y);
  81. void SetRectValue(CImage *pImg,int x,int y,int Dx,int Dy,BYTE *buf);
  82. void GetAllPalette(CImage *pImg,RGBQUAD *ColorTab);
  83. void SetAllPalette(CImage *pImg,RGBQUAD *ColorTab);
  84. int PaletteType(RGBQUAD *ColorTab);
  85. int ImageType();
  86. void RotateCimage(CImage *Imgn, int nAngle);
  87. };
  88. //////////////////////////////////////////////////////////////////////////////////
  89. #endif