123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- #pragma once
- // CDlgRenderings 对话框
- #define RCARRARCOUNT 100
- typedef struct __OFFSETINFO__ {
- INT nIndexOfAlpha; // PNG图片上的透明区域索引;
- INT nXOffSet; // JPG在透明区域上的x偏移量;
- INT nYOffSet; // JPG在透明区域上的y偏移量;
- Image *pImage; // JPG图片对象;
- float fScale; // JPG在适应到PNG透明区域后的缩放系数(适应后的值是1.0,以此为基础再缩放);
- __OFFSETINFO__()
- {
- nIndexOfAlpha = 0;
- nXOffSet = 0;
- nYOffSet = 0;
- pImage = NULL;
- fScale = 1.0;
- }
- }STOffSetInfo, *pSTOffSetInfo;
- // 透明区域的3个有效位置点(用来确认一个矩形);
- typedef struct __ALPHA_PT__ {
- INT nAlphaIndex; // 索引;
- CPoint ptOrigin; // 原点;
- CPoint ptOriginX; // 原点x轴方向的点;
- CPoint ptOriginY; // 原点y轴方向的点;
- __ALPHA_PT__() :nAlphaIndex(-1), ptOrigin(0, 0), ptOriginX(0, 0), ptOriginY(0, 0) {}
- }STAlphaPt, *pSTAlphaPt;
- // 每张PNG的透明区域信息;
- typedef struct __PNG_ALPHA__ {
- CString PNGFileName; // PNG图片路径;
- float fScale; // PNG【适应】缩放到背景区域的缩放值;
- CRect rcZoom; // PNG【适应】缩放到背景区域的显示区域;
- vector<STAlphaPt> vtAlphaPt; // PNG图片上的透明区域;
- __PNG_ALPHA__() :PNGFileName(""), fScale(0.0) {}
- }STImageAlpha, *pSTImageAlpha;
- class CDlgRenderings : public CDialog
- {
- DECLARE_DYNAMIC(CDlgRenderings)
- public:
- CDlgRenderings(CWnd* pParent = NULL); // 标准构造函数
- virtual ~CDlgRenderings();
- // 对话框数据
- enum { IDD = IDD_RENDERINGS_DIALOG };
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
- DECLARE_MESSAGE_MAP()
- public:
- virtual BOOL OnInitDialog();
- afx_msg void OnPaint();
-
- public:
- CListCtrl m_ListPNG;
- CListCtrl m_ListJPG;
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg void OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnNMClickList2(NMHDR *pNMHDR, LRESULT *pResult);
- afx_msg void OnDestroy();
- afx_msg void OnBnClickedAdd();
- afx_msg void OnBnClickedDelete();
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- public:
- float m_tempscale;
- Bitmap *m_pImagebak;
- BOOL m_bLoadEffectPNGImg;
- BOOL m_bLoadPhotoJPGImg;
- CArray<int, int>m_rcarray[RCARRARCOUNT]; // m_rcarray数组,用于记录PNG图片里的alpha色小于200的像素点坐标;
- Bitmap *m_pPNGImage;
- Image *m_pJPGImage;
- float m_fscale;
- CRect m_rcscreen;
- CPoint m_startpt;
- CPoint m_startpt2;
- CStringArray m_AryEffectPNGImg;
- int m_nSelectPNGPosition;
- int m_nSelectJPGPosition;
- Bitmap *m_pbmp;// m_pbmp:最终显示PNG效果图的Bimap对象(PNG+客人相片 合二为一的结果);
- CRect m_rc;
- CRect m_rcbak;
-
- CStringArray m_strArray;
- CStringArray *m_pPhotopatharray;
- #ifdef __UN_USE__
- void InitRc(Image *img);
- void MakeEffect();
- void GetRgn(Bitmap *pBmpImage);
- #endif
- CStringArray m_vPNGFile;
- CImageList m_ImageListThumb; // image list holding the thumbnails
- bool m_bRunning; // Flag to whether thread is on running or not
- bool m_bTerminate; // Flag to Thread to be terminated
- unsigned int m_dwThreadID; // Thread ID
- HANDLE m_hThread, m_hEvent; // Thread and Event handle
- BOOL TerminateThread();
- CStringArray m_vJPGFile;
- CImageList m_ImageListThumb2; // image list holding the thumbnails
- bool m_bRunning2; // Flag to whether thread is on running or not
- bool m_bTerminate2; // Flag to Thread to be terminated
- unsigned int m_dwThreadID2; // Thread ID
- HANDLE m_hThread2, m_hEvent2; // Thread and Event handle
- BOOL TerminateThread2();
- public:
- //CDC *m_pBackgroundDC;
- CPoint m_ptLastRectangle;
- static ThreadSection m_cs;
- CRect m_rcPNGImage;
- CRect m_rcBackground;
- static CRect m_rcWndClient;
- BOOL m_nCurAlphaIndex;
- BOOL m_bMousePress;
- vector<STOffSetInfo> m_vtOffSetInfo;
- #ifdef __UN_USE__
- BOOL LoadPNGImage(IN INT nIndex);
- #endif
- BOOL LoadPNGImageSuper(IN INT nIndex);
- static CRect InitRect(IN Image* pImage);
- #ifdef __UN_USE__
- BOOL LoadJPGImage(IN INT nAlphaIndex, IN Image* pJpgImage, IN INT nXOffset = 0, IN INT nYOffset = 0);
- #endif
- // 首次调用顾客相片时用;
- BOOL LoadJPGImageSuper(IN STOffSetInfo *pOffSetInfo);
- BOOL LoadJPGImageSuperEx(IN STOffSetInfo *pOffSetInfo);
- BOOL LoadJPGImageSuperEx(IN INT nAlphaIndex, IN Image* pJpgImage, IN float &fs, IN INT nXOffset = 0, IN INT nYOffset = 0);
- INT IsPointInAlphaRect(IN CPoint point);
- // 将窗口点坐标系转到透明区域点坐标系;
- CPoint WndPt2AlphaPt(IN const CPoint& WndPt);
- CPoint WndPt2AlphaPt(IN const CPoint& WndPt, IN CRect& rcPNGImage, IN float fScale);
- // 将透明区域点坐标系转到窗口点坐标系;
- CPoint AlphaPt2WndPt(IN const CPoint& AlphaPt);
- CPoint AlphaPt2WndPt(IN const CPoint& AlphaPt, IN CRect& rcPNGImage, IN float fScale);
- // 透明区域是否存在;
- static BOOL IsAlphaIndexExist(IN INT nIndex, vector<STAlphaPt> &vtAlpha);
- static BOOL IsPngAlphaExist(IN CString strPng, vector<STImageAlpha> &vtPngAlpha);
- // 获取PNG的透明区域信息;
- static void GetPNGAlphaRectInfo(IN Bitmap *pOriginImage, IN OUT STImageAlpha& pngAlpha);
- static vector<STImageAlpha> m_vtPngAlphaInfo;
- // 线程:获取所有PNG透明区域信息;
- static DWORD WINAPI Thread_GetAllPNGInfo(IN LPVOID lpVoid);
- // 画边线;
- void DrawAlphaEdge(IN CPoint pt, IN BOOL bWhite = FALSE);
- // 添加新元素到list列表中;
- void AddNewImageItem(IN CString strImageFile);
- afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
- };
|