-
Notifications
You must be signed in to change notification settings - Fork 4
/
RefColorDlg.cpp
239 lines (199 loc) · 6.17 KB
/
RefColorDlg.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2005-2011 Association Homecinema Francophone. All rights reserved.
/////////////////////////////////////////////////////////////////////////////
//
// This file is subject to the terms of the GNU General Public License as
// published by the Free Software Foundation. A copy of this license is
// included with this software distribution in the file COPYING.htm. If you
// do not have a copy, you may obtain a copy by writing to the Free
// Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details
/////////////////////////////////////////////////////////////////////////////
// Author(s):
// Georges GALLERAND
/////////////////////////////////////////////////////////////////////////////
// RefColorDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ColorHCFR.h"
#include "RefColorDlg.h"
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRefColorDlg dialog
CRefColorDlg::CRefColorDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRefColorDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRefColorDlg)
m_red1 = 0.412;
m_red2 = 0.213;
m_red3 = 0.019;
m_green1 = 0.358;
m_green2 = 0.715;
m_green3 = 0.119;
m_blue1 = 0.180;
m_blue2 = 0.072;
m_blue3 = 0.951;
m_white1 = 0.950;
m_white2 = 1.0;
m_white3 = 1.089;
//}}AFX_DATA_INIT
m_RedColor = noDataColor;
m_GreenColor = noDataColor;
m_BlueColor = noDataColor;
m_WhiteColor = noDataColor;
m_bxyY = FALSE;
}
void CRefColorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRefColorDlg)
DDX_Control(pDX, IDC_STATIC_1, m_label1);
DDX_Control(pDX, IDC_STATIC_2, m_label2);
DDX_Control(pDX, IDC_STATIC_3, m_label3);
DDX_Text(pDX, IDC_RED_1, m_red1);
DDX_Text(pDX, IDC_RED_2, m_red2);
DDX_Text(pDX, IDC_RED_3, m_red3);
DDX_Text(pDX, IDC_GREEN_1, m_green1);
DDX_Text(pDX, IDC_GREEN_2, m_green2);
DDX_Text(pDX, IDC_GREEN_3, m_green3);
DDX_Text(pDX, IDC_BLUE_1, m_blue1);
DDX_Text(pDX, IDC_BLUE_2, m_blue2);
DDX_Text(pDX, IDC_BLUE_3, m_blue3);
DDX_Text(pDX, IDC_WHITE_1, m_white1);
DDX_Text(pDX, IDC_WHITE_2, m_white2);
DDX_Text(pDX, IDC_WHITE_3, m_white3);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRefColorDlg, CDialog)
//{{AFX_MSG_MAP(CRefColorDlg)
ON_BN_CLICKED(ID_HELP, OnHelp)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRefColorDlg message handlers
BOOL CRefColorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CheckRadioButton ( IDC_RADIO1, IDC_RADIO2, IDC_RADIO1 );
m_bxyY = FALSE;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRefColorDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CRefColorDlg::OnOK()
{
UpdateData (TRUE);
if ( IsDlgButtonChecked ( IDC_RADIO1 ) )
{
m_RedColor[0]=m_red1;
m_RedColor[1]=m_red2;
m_RedColor[2]=m_red3;
m_GreenColor[0]=m_green1;
m_GreenColor[1]=m_green2;
m_GreenColor[2]=m_green3;
m_BlueColor[0]=m_blue1;
m_BlueColor[1]=m_blue2;
m_BlueColor[2]=m_blue3;
m_WhiteColor[0]=m_white1;
m_WhiteColor[1]=m_white2;
m_WhiteColor[2]=m_white3;
}
else
{
ColorxyY aColor;
aColor[0]=m_red1;
aColor[1]=m_red2;
aColor[2]=m_red3;
m_RedColor.SetxyYValue(aColor);
aColor[0]=m_green1;
aColor[1]=m_green2;
aColor[2]=m_green3;
m_GreenColor.SetxyYValue(aColor);
aColor[0]=m_blue1;
aColor[1]=m_blue2;
aColor[2]=m_blue3;
m_BlueColor.SetxyYValue(aColor);
aColor[0]=m_white1;
aColor[1]=m_white2;
aColor[2]=m_white3;
m_WhiteColor.SetxyYValue(aColor);
}
CDialog::OnOK();
}
void CRefColorDlg::OnHelp()
{
GetConfig () -> DisplayHelp ( HID_COLOR_REFERENCES, NULL );
}
BOOL CRefColorDlg::OnHelpInfo(HELPINFO* pHelpInfo)
{
OnHelp ();
return TRUE;
}
void convertxyYtoXYZ(double& value1, double& value2, double& value3)
{
ColorxyY aColor(value1, value2, value3);
ColorXYZ aColor2(aColor);
value1=floor( aColor2[0] * 1000.0 + 0.5 ) / 1000.0;
value2=floor( aColor2[1] * 1000.0 + 0.5 ) / 1000.0;
value3=floor( aColor2[2] * 1000.0 + 0.5 ) / 1000.0;
}
void convertXYZtoxyY(double& value1, double& value2, double& value3)
{
ColorXYZ aColor(value1, value2, value3);
ColorxyY aColor2(aColor);
value1=floor( aColor2[0] * 1000.0 + 0.5 ) / 1000.0;
value2=floor( aColor2[1] * 1000.0 + 0.5 ) / 1000.0;
value3=floor( aColor2[2] * 1000.0 + 0.5 ) / 1000.0;
}
void CRefColorDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
m_label1.SetWindowText ( "X:" );
m_label2.SetWindowText ( "Y:" );
m_label3.SetWindowText ( "Z:" );
if ( m_bxyY )
{
// Convert xyY values to XYZ values
UpdateData(TRUE);
convertxyYtoXYZ(m_red1, m_red2, m_red3);
convertxyYtoXYZ(m_green1, m_green2, m_green3);
convertxyYtoXYZ(m_blue1, m_blue2, m_blue3);
convertxyYtoXYZ(m_white1, m_white2, m_white3);
UpdateData(FALSE);
}
m_bxyY = FALSE;
}
void CRefColorDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
m_label1.SetWindowText ( "x:" );
m_label2.SetWindowText ( "y:" );
m_label3.SetWindowText ( "Y:" );
if ( ! m_bxyY )
{
// Convert XYZ values to xyY values
UpdateData(TRUE);
convertXYZtoxyY(m_red1, m_red2, m_red3);
convertXYZtoxyY(m_green1, m_green2, m_green3);
convertXYZtoxyY(m_blue1, m_blue2, m_blue3);
convertXYZtoxyY(m_white1, m_white2, m_white3);
UpdateData(FALSE);
}
m_bxyY = TRUE;
}