Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Conversions.h
1 /***********************************************************************
2 filename: CEGUIColourPickerConversions.h
3 created: 20th February 2010
4 author: Lukas E Meindl
5 
6 purpose: Header of the class used to provide conversions between
7 the ColourPicker colour types
8 *************************************************************************/
9 /***************************************************************************
10 * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining
13 * a copy of this software and associated documentation files (the
14 * "Software"), to deal in the Software without restriction, including
15 * without limitation the rights to use, copy, modify, merge, publish,
16 * distribute, sublicense, and/or sell copies of the Software, and to
17 * permit persons to whom the Software is furnished to do so, subject to
18 * the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be
21 * included in all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 * OTHER DEALINGS IN THE SOFTWARE.
30 ***************************************************************************/
31 #ifndef _CEGUIColourPickerConversions_h_
32 #define _CEGUIColourPickerConversions_h_
33 
34 #include "CEGUI/CommonDialogs/Module.h"
35 #include "CEGUI/CommonDialogs/ColourPicker/Types.h"
36 #include "CEGUI/Colour.h"
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 namespace CEGUI
44 {
45 
46 class CEGUI_COMMONDIALOGS_API ColourPickerConversions
47 {
48 public:
50  static Lab_Colour toLab(RGB_Colour colour);
51 
53  static HSV_Colour toHSV(RGB_Colour colour);
54 
56  static RGB_Colour toRGB(const Lab_Colour& colour);
57 
59  static RGB_Colour toRGB(float L, float a, float b);
60 
62  static RGB_Colour toRGB(const CEGUI::Colour& colour);
63 
65  static RGB_Colour toRGB(const HSV_Colour& colour);
66 
68  static CEGUI::Colour toCeguiColour(const RGB_Colour& colourRGB);
69 
71  static float toX(unsigned char R, unsigned char G, unsigned char B);
72 
74  static float toY(unsigned char R, unsigned char G, unsigned char B);
75 
77  static float toZ(unsigned char R, unsigned char G, unsigned char B);
78 
80  static float toX(float R, float G, float B);
81 
83  static float toY(float R, float G, float B);
84 
86  static float toZ(float R, float G, float B);
87 
89  static float toL(float Y);
90 
92  static float toA(float X, float Y);
93 
95  static float toB(float Y, float Z);
96 
98  static RGB_Colour linearInterpolationRGB(float interPolBalance,
99  const RGB_Colour& start,
100  const RGB_Colour& end);
101 
103  static unsigned char linearInterpolationAlpha(float interPolBalance,
104  unsigned char startAlpha,
105  unsigned char endAlpha);
106 
108  static Lab_Colour linearInterpolationLab(float interPolBalance,
109  const Lab_Colour& start,
110  const Lab_Colour& end);
111 
113  static HSV_Colour linearInterpolationHSV(float interPolBalance,
114  const HSV_Colour& start,
115  const HSV_Colour& end);
116 
117 private:
119  static void clampInterpolationValue(float& interPolBalance);
120 
122  static float normCalc(float div);
123 
125  static float XNormCalc(float X);
126 
128  static float YNormCalc(float Y);
129 
131  static float ZNormCalc(float Z);
132 
134  static void clamp(float& value, float min_val, float max_val);
135 
137  static const float Xn;
138  static const float Yn;
139  static const float Zn;
140 
142  // values of P/Pn (P/Pn < LAB_COMPARE_VALUE_CONST)
143  static const float LAB_COMPARE_VALUE_CONST;
144 };
145 
146 }
147 
148 #if defined(_MSC_VER)
149 # pragma warning(pop)
150 #endif
151 
152 
153 #endif
154