1 | /*****************************************************************************/ |
2 | // Copyright 2006 Adobe Systems Incorporated |
3 | // All Rights Reserved. |
4 | // |
5 | // NOTICE: Adobe permits you to use, modify, and distribute this file in |
6 | // accordance with the terms of the Adobe license agreement accompanying it. |
7 | /*****************************************************************************/ |
8 | |
9 | /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_xy_coord.h#2 $ */ |
10 | /* $DateTime: 2012/07/31 22:04:34 $ */ |
11 | /* $Change: 840853 $ */ |
12 | /* $Author: tknoll $ */ |
13 | |
14 | /** \file |
15 | * Representation of colors in xy and XYZ coordinates. |
16 | */ |
17 | |
18 | /*****************************************************************************/ |
19 | |
20 | #ifndef __dng_xy_coord__ |
21 | #define __dng_xy_coord__ |
22 | |
23 | /*****************************************************************************/ |
24 | |
25 | #include "dng_classes.h" |
26 | #include "dng_types.h" |
27 | |
28 | /*****************************************************************************/ |
29 | |
30 | class dng_xy_coord |
31 | { |
32 | |
33 | public: |
34 | |
35 | real64 x; |
36 | real64 y; |
37 | |
38 | public: |
39 | |
40 | dng_xy_coord () |
41 | : x (0.0) |
42 | , y (0.0) |
43 | { |
44 | } |
45 | |
46 | dng_xy_coord (real64 xx, real64 yy) |
47 | : x (xx) |
48 | , y (yy) |
49 | { |
50 | } |
51 | |
52 | void Clear () |
53 | { |
54 | x = 0.0; |
55 | y = 0.0; |
56 | } |
57 | |
58 | bool IsValid () const |
59 | { |
60 | return x > 0.0 && |
61 | y > 0.0; |
62 | } |
63 | |
64 | bool NotValid () const |
65 | { |
66 | return !IsValid (); |
67 | } |
68 | |
69 | bool operator== (const dng_xy_coord &coord) const |
70 | { |
71 | return coord.x == x && |
72 | coord.y == y; |
73 | } |
74 | |
75 | bool operator!= (const dng_xy_coord &coord) const |
76 | { |
77 | return !(*this == coord); |
78 | } |
79 | |
80 | }; |
81 | |
82 | /*****************************************************************************/ |
83 | |
84 | inline dng_xy_coord operator+ (const dng_xy_coord &A, |
85 | const dng_xy_coord &B) |
86 | { |
87 | |
88 | dng_xy_coord C; |
89 | |
90 | C.x = A.x + B.x; |
91 | C.y = A.y + B.y; |
92 | |
93 | return C; |
94 | |
95 | } |
96 | |
97 | /*****************************************************************************/ |
98 | |
99 | inline dng_xy_coord operator- (const dng_xy_coord &A, |
100 | const dng_xy_coord &B) |
101 | { |
102 | |
103 | dng_xy_coord C; |
104 | |
105 | C.x = A.x - B.x; |
106 | C.y = A.y - B.y; |
107 | |
108 | return C; |
109 | |
110 | } |
111 | |
112 | /*****************************************************************************/ |
113 | |
114 | inline dng_xy_coord operator* (real64 scale, |
115 | const dng_xy_coord &A) |
116 | { |
117 | |
118 | dng_xy_coord B; |
119 | |
120 | B.x = A.x * scale; |
121 | B.y = A.y * scale; |
122 | |
123 | return B; |
124 | |
125 | } |
126 | |
127 | /******************************************************************************/ |
128 | |
129 | inline real64 operator* (const dng_xy_coord &A, |
130 | const dng_xy_coord &B) |
131 | { |
132 | |
133 | return A.x * B.x + |
134 | A.y * B.y; |
135 | |
136 | } |
137 | |
138 | /*****************************************************************************/ |
139 | |
140 | // Standard xy coordinate constants. |
141 | |
142 | inline dng_xy_coord StdA_xy_coord () |
143 | { |
144 | return dng_xy_coord (0.4476, 0.4074); |
145 | } |
146 | |
147 | inline dng_xy_coord D50_xy_coord () |
148 | { |
149 | return dng_xy_coord (0.3457, 0.3585); |
150 | } |
151 | |
152 | inline dng_xy_coord D55_xy_coord () |
153 | { |
154 | return dng_xy_coord (0.3324, 0.3474); |
155 | } |
156 | |
157 | inline dng_xy_coord D65_xy_coord () |
158 | { |
159 | return dng_xy_coord (0.3127, 0.3290); |
160 | } |
161 | |
162 | inline dng_xy_coord D75_xy_coord () |
163 | { |
164 | return dng_xy_coord (0.2990, 0.3149); |
165 | } |
166 | |
167 | /*****************************************************************************/ |
168 | |
169 | // Convert between xy coordinates and XYZ coordinates. |
170 | |
171 | dng_xy_coord XYZtoXY (const dng_vector_3 &coord); |
172 | |
173 | dng_vector_3 XYtoXYZ (const dng_xy_coord &coord); |
174 | |
175 | /*****************************************************************************/ |
176 | |
177 | // Returns the ICC XYZ profile connection space white point. |
178 | |
179 | dng_xy_coord PCStoXY (); |
180 | |
181 | dng_vector_3 PCStoXYZ (); |
182 | |
183 | /*****************************************************************************/ |
184 | |
185 | #endif |
186 | |
187 | /*****************************************************************************/ |
188 | |