DlgRenderings.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #pragma once
  2. // CDlgRenderings 对话框
  3. #define RCARRARCOUNT 100
  4. typedef struct __OFFSETINFO__ {
  5. INT nIndexOfAlpha; // PNG图片上的透明区域索引;
  6. INT nXOffSet; // JPG在透明区域上的x偏移量;
  7. INT nYOffSet; // JPG在透明区域上的y偏移量;
  8. Image *pImage; // JPG图片对象;
  9. float fScale; // JPG在适应到PNG透明区域后的缩放系数(适应后的值是1.0,以此为基础再缩放);
  10. __OFFSETINFO__()
  11. {
  12. nIndexOfAlpha = 0;
  13. nXOffSet = 0;
  14. nYOffSet = 0;
  15. pImage = NULL;
  16. fScale = 1.0;
  17. }
  18. }STOffSetInfo, *pSTOffSetInfo;
  19. // 透明区域的3个有效位置点(用来确认一个矩形);
  20. typedef struct __ALPHA_PT__ {
  21. INT nAlphaIndex; // 索引;
  22. CPoint ptOrigin; // 原点;
  23. CPoint ptOriginX; // 原点x轴方向的点;
  24. CPoint ptOriginY; // 原点y轴方向的点;
  25. __ALPHA_PT__() :nAlphaIndex(-1), ptOrigin(0, 0), ptOriginX(0, 0), ptOriginY(0, 0) {}
  26. }STAlphaPt, *pSTAlphaPt;
  27. // 每张PNG的透明区域信息;
  28. typedef struct __PNG_ALPHA__ {
  29. CString PNGFileName; // PNG图片路径;
  30. float fScale; // PNG【适应】缩放到背景区域的缩放值;
  31. CRect rcZoom; // PNG【适应】缩放到背景区域的显示区域;
  32. vector<STAlphaPt> vtAlphaPt; // PNG图片上的透明区域;
  33. __PNG_ALPHA__() :PNGFileName(""), fScale(0.0) {}
  34. }STImageAlpha, *pSTImageAlpha;
  35. class CDlgRenderings : public CDialog
  36. {
  37. DECLARE_DYNAMIC(CDlgRenderings)
  38. public:
  39. CDlgRenderings(CWnd* pParent = NULL); // 标准构造函数
  40. virtual ~CDlgRenderings();
  41. // 对话框数据
  42. enum { IDD = IDD_RENDERINGS_DIALOG };
  43. protected:
  44. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  45. DECLARE_MESSAGE_MAP()
  46. public:
  47. virtual BOOL OnInitDialog();
  48. afx_msg void OnPaint();
  49. public:
  50. CListCtrl m_ListPNG;
  51. CListCtrl m_ListJPG;
  52. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  53. afx_msg void OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult);
  54. afx_msg void OnNMClickList2(NMHDR *pNMHDR, LRESULT *pResult);
  55. afx_msg void OnDestroy();
  56. afx_msg void OnBnClickedAdd();
  57. afx_msg void OnBnClickedDelete();
  58. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  59. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  60. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  61. virtual BOOL PreTranslateMessage(MSG* pMsg);
  62. public:
  63. float m_tempscale;
  64. Bitmap *m_pImagebak;
  65. BOOL m_bLoadEffectPNGImg;
  66. BOOL m_bLoadPhotoJPGImg;
  67. CArray<int, int>m_rcarray[RCARRARCOUNT]; // m_rcarray数组,用于记录PNG图片里的alpha色小于200的像素点坐标;
  68. Bitmap *m_pPNGImage;
  69. Image *m_pJPGImage;
  70. float m_fscale;
  71. CRect m_rcscreen;
  72. CPoint m_startpt;
  73. CPoint m_startpt2;
  74. CStringArray m_AryEffectPNGImg;
  75. int m_nSelectPNGPosition;
  76. int m_nSelectJPGPosition;
  77. Bitmap *m_pbmp;// m_pbmp:最终显示PNG效果图的Bimap对象(PNG+客人相片 合二为一的结果);
  78. CRect m_rc;
  79. CRect m_rcbak;
  80. CStringArray m_strArray;
  81. CStringArray *m_pPhotopatharray;
  82. #ifdef __UN_USE__
  83. void InitRc(Image *img);
  84. void MakeEffect();
  85. void GetRgn(Bitmap *pBmpImage);
  86. #endif
  87. CStringArray m_vPNGFile;
  88. CImageList m_ImageListThumb; // image list holding the thumbnails
  89. bool m_bRunning; // Flag to whether thread is on running or not
  90. bool m_bTerminate; // Flag to Thread to be terminated
  91. unsigned int m_dwThreadID; // Thread ID
  92. HANDLE m_hThread, m_hEvent; // Thread and Event handle
  93. BOOL TerminateThread();
  94. CStringArray m_vJPGFile;
  95. CImageList m_ImageListThumb2; // image list holding the thumbnails
  96. bool m_bRunning2; // Flag to whether thread is on running or not
  97. bool m_bTerminate2; // Flag to Thread to be terminated
  98. unsigned int m_dwThreadID2; // Thread ID
  99. HANDLE m_hThread2, m_hEvent2; // Thread and Event handle
  100. BOOL TerminateThread2();
  101. public:
  102. //CDC *m_pBackgroundDC;
  103. CPoint m_ptLastRectangle;
  104. static ThreadSection m_cs;
  105. CRect m_rcPNGImage;
  106. CRect m_rcBackground;
  107. static CRect m_rcWndClient;
  108. BOOL m_nCurAlphaIndex;
  109. BOOL m_bMousePress;
  110. vector<STOffSetInfo> m_vtOffSetInfo;
  111. #ifdef __UN_USE__
  112. BOOL LoadPNGImage(IN INT nIndex);
  113. #endif
  114. BOOL LoadPNGImageSuper(IN INT nIndex);
  115. static CRect InitRect(IN Image* pImage);
  116. #ifdef __UN_USE__
  117. BOOL LoadJPGImage(IN INT nAlphaIndex, IN Image* pJpgImage, IN INT nXOffset = 0, IN INT nYOffset = 0);
  118. #endif
  119. // 首次调用顾客相片时用;
  120. BOOL LoadJPGImageSuper(IN STOffSetInfo *pOffSetInfo);
  121. BOOL LoadJPGImageSuperEx(IN STOffSetInfo *pOffSetInfo);
  122. BOOL LoadJPGImageSuperEx(IN INT nAlphaIndex, IN Image* pJpgImage, IN float &fs, IN INT nXOffset = 0, IN INT nYOffset = 0);
  123. INT IsPointInAlphaRect(IN CPoint point);
  124. // 将窗口点坐标系转到透明区域点坐标系;
  125. CPoint WndPt2AlphaPt(IN const CPoint& WndPt);
  126. CPoint WndPt2AlphaPt(IN const CPoint& WndPt, IN CRect& rcPNGImage, IN float fScale);
  127. // 将透明区域点坐标系转到窗口点坐标系;
  128. CPoint AlphaPt2WndPt(IN const CPoint& AlphaPt);
  129. CPoint AlphaPt2WndPt(IN const CPoint& AlphaPt, IN CRect& rcPNGImage, IN float fScale);
  130. // 透明区域是否存在;
  131. static BOOL IsAlphaIndexExist(IN INT nIndex, vector<STAlphaPt> &vtAlpha);
  132. static BOOL IsPngAlphaExist(IN CString strPng, vector<STImageAlpha> &vtPngAlpha);
  133. // 获取PNG的透明区域信息;
  134. static void GetPNGAlphaRectInfo(IN Bitmap *pOriginImage, IN OUT STImageAlpha& pngAlpha);
  135. static vector<STImageAlpha> m_vtPngAlphaInfo;
  136. // 线程:获取所有PNG透明区域信息;
  137. static DWORD WINAPI Thread_GetAllPNGInfo(IN LPVOID lpVoid);
  138. // 画边线;
  139. void DrawAlphaEdge(IN CPoint pt, IN BOOL bWhite = FALSE);
  140. // 添加新元素到list列表中;
  141. void AddNewImageItem(IN CString strImageFile);
  142. afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
  143. };