-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMirrorDialog.cpp
106 lines (77 loc) · 2.41 KB
/
CMirrorDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// CMirrorDialog.cpp: 实现文件
//
#include "pch.h"
#include "BmpView.h"
#include "afxdialogex.h"
#include "CMirrorDialog.h"
#define MAX_WIDTH 3840
#define MAX_HEIGHT 2160
#define IMG_MAX_SIZE (MAX_WIDTH*MAX_HEIGHT)
static unsigned char img_temp[IMG_MAX_SIZE * 3] = { 0 };
// CMirrorDialog 对话框
IMPLEMENT_DYNAMIC(CMirrorDialog, CDialogEx)
CMirrorDialog::CMirrorDialog(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_IMAGE_MIRRIOR_DIALOG, pParent), m_imgWidth(0), m_imgHeight(0), m_imgData(nullptr)
{
}
CMirrorDialog::~CMirrorDialog()
{
}
void CMirrorDialog::OnHorizontalMirror()
{
if (m_imgData == nullptr) {
AfxMessageBox(_T("图像数据为空"));
return;
}
MirrorImageHorizontally(m_imgWidth, m_imgHeight, m_imgData, img_temp);
// 创建一个新的 CProcessedImageDialog 对象
CProcessedImageDialog dlgProcessed;
// 设置处理后的图像数据
dlgProcessed.SetImageData(m_imgWidth, m_imgHeight, img_temp, "水平镜像");
// 显示对话框
dlgProcessed.DoModal();
}
void CMirrorDialog::OnVerticalMirror()
{
if (m_imgData == nullptr) {
AfxMessageBox(_T("图像数据为空"));
return;
}
MirrorImageVertically(m_imgWidth, m_imgHeight, m_imgData, img_temp);
// 创建一个新的 CProcessedImageDialog 对象
CProcessedImageDialog dlgProcessed;
// 设置处理后的图像数据
dlgProcessed.SetImageData(m_imgWidth, m_imgHeight, img_temp, "垂直镜像");
// 显示对话框
dlgProcessed.DoModal();
}
void CMirrorDialog::OnDiagonalMirror()
{
if (m_imgData == nullptr) {
AfxMessageBox(_T("图像数据为空"));
return;
}
MirrorImageDiagonally(m_imgWidth, m_imgHeight, m_imgData, img_temp);
// 创建一个新的 CProcessedImageDialog 对象
CProcessedImageDialog dlgProcessed;
// 设置处理后的图像数据
dlgProcessed.SetImageData(m_imgWidth, m_imgHeight, img_temp, "对角镜像");
// 显示对话框
dlgProcessed.DoModal();
}
void CMirrorDialog::SetImageData(int width, int height, unsigned char* imgData)
{
m_imgWidth = width;
m_imgHeight = height;
m_imgData = imgData;
}
void CMirrorDialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CMirrorDialog, CDialogEx)
ON_BN_CLICKED(ID_HORIZONTAL_MIRROR, &CMirrorDialog::OnHorizontalMirror)
ON_BN_CLICKED(ID_VERTICAL_MIRROR, &CMirrorDialog::OnVerticalMirror)
ON_BN_CLICKED(ID_DIAGONAL_MIRROR, &CMirrorDialog::OnDiagonalMirror)
END_MESSAGE_MAP()
// CMirrorDialog 消息处理程序