summaryrefslogtreecommitdiff
path: root/source/dng_xy_coord.h
blob: daf212561df1aaca7beb234907a29ba8615adf98 (plain)
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
/*****************************************************************************/
// Copyright 2006 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/

/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_xy_coord.h#2 $ */ 
/* $DateTime: 2012/07/31 22:04:34 $ */
/* $Change: 840853 $ */
/* $Author: tknoll $ */

/** \file
 * Representation of colors in xy and XYZ coordinates.
 */

/*****************************************************************************/

#ifndef __dng_xy_coord__
#define __dng_xy_coord__

/*****************************************************************************/

#include "dng_classes.h"
#include "dng_types.h"

/*****************************************************************************/

class dng_xy_coord
	{
	
	public:
	
		real64 x;
		real64 y;
		
	public:
	
		dng_xy_coord ()
			:	x (0.0)
			,	y (0.0)
			{
			}
			
		dng_xy_coord (real64 xx, real64 yy)
			:	x (xx)
			,	y (yy)
			{
			}
			
		void Clear ()
			{
			x = 0.0;
			y = 0.0;
			}
			
		bool IsValid () const
			{
			return x > 0.0 &&
				   y > 0.0;
			}

		bool NotValid () const
			{
			return !IsValid ();
			}

		bool operator== (const dng_xy_coord &coord) const
			{
			return coord.x == x &&
				   coord.y == y;
			}

		bool operator!= (const dng_xy_coord &coord) const
			{
			return !(*this == coord);
			}

	};

/*****************************************************************************/

inline dng_xy_coord operator+ (const dng_xy_coord &A,
							   const dng_xy_coord &B)
	{
	
	dng_xy_coord C;
	
	C.x = A.x + B.x;
	C.y = A.y + B.y;
	
	return C;
	
	}
			
/*****************************************************************************/

inline dng_xy_coord operator- (const dng_xy_coord &A,
							   const dng_xy_coord &B)
	{
	
	dng_xy_coord C;
	
	C.x = A.x - B.x;
	C.y = A.y - B.y;
	
	return C;
	
	}
			
/*****************************************************************************/

inline dng_xy_coord operator* (real64 scale,
							   const dng_xy_coord &A)
	{
	
	dng_xy_coord B;
	
	B.x = A.x * scale;
	B.y = A.y * scale;
	
	return B;
	
	}
			
/******************************************************************************/

inline real64 operator* (const dng_xy_coord &A,
						 const dng_xy_coord &B)
	{
	
	return A.x * B.x +
		   A.y * B.y;
	
	}

/*****************************************************************************/

// Standard xy coordinate constants.

inline dng_xy_coord StdA_xy_coord ()
	{
	return dng_xy_coord (0.4476, 0.4074);
	}

inline dng_xy_coord D50_xy_coord ()
	{
	return dng_xy_coord (0.3457, 0.3585);
	}

inline dng_xy_coord D55_xy_coord ()
	{
	return dng_xy_coord (0.3324, 0.3474);
	}

inline dng_xy_coord D65_xy_coord ()
	{
	return dng_xy_coord (0.3127, 0.3290);
	}

inline dng_xy_coord D75_xy_coord ()
	{
	return dng_xy_coord (0.2990, 0.3149);
	}

/*****************************************************************************/

// Convert between xy coordinates and XYZ coordinates.

dng_xy_coord XYZtoXY (const dng_vector_3 &coord);

dng_vector_3 XYtoXYZ (const dng_xy_coord &coord);

/*****************************************************************************/

// Returns the ICC XYZ profile connection space white point.

dng_xy_coord PCStoXY ();

dng_vector_3 PCStoXYZ ();

/*****************************************************************************/

#endif
	
/*****************************************************************************/