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