-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGammaCurveDialog.cpp
66 lines (49 loc) · 1.25 KB
/
GammaCurveDialog.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
// GammaCurveDialog.cpp: 实现文件
//
#include "pch.h"
#include "BmpView.h"
#include "afxdialogex.h"
#include "GammaCurveDialog.h"
// GammaCurveDialog 对话框
IMPLEMENT_DYNAMIC(GammaCurveDialog, CDialogEx)
GammaCurveDialog::GammaCurveDialog(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_GAMMA_CURVE_DIALOG, pParent)
{
m_gamma = 1.0;
}
GammaCurveDialog::~GammaCurveDialog()
{
}
void GammaCurveDialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
void GammaCurveDialog::OnPaint()
{
CPaintDC dc(this); // 设备上下文用于绘画
// 获取绘图区的尺寸
CRect rect;
GetClientRect(&rect);
// 设置伽马值
double gamma = m_gamma;
// 定义绘图区域
int width = rect.Width();
int height = rect.Height();
CPen gammaPen(PS_SOLID, 2, RGB(0, 0, 255)); // 蓝色画笔绘制伽马曲线
// 绘制伽马曲线
dc.SelectObject(&gammaPen);
for (int i = 0; i < width; ++i)
{
double normalizedInput = i / (double)width;
double normalizedOutput = pow(normalizedInput, gamma);
int y = height - (int)(normalizedOutput * height);
if (i == 0)
dc.MoveTo(i, y);
else
dc.LineTo(i, y);
}
}
BEGIN_MESSAGE_MAP(GammaCurveDialog, CDialogEx)
ON_WM_PAINT()
END_MESSAGE_MAP()
// GammaCurveDialog 消息处理程序