Jamoma API  0.6.0.a19
ColorDataspace.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup foundationDataspaceLib
4  *
5  * @brief The #ColorDataspace converts between different measurement units describing colors.
6  *
7  * @details Possible units are CMY, HSL, HSV, RGB and RGB8. The neutral unit of the color dataspace is RGB where each of the color values is normalised to the [0, 1] range.@n
8  * @n
9  * @n
10  * Code for RGB <-> HSV convertion is in part based on source code provided by Marcelo Gattass:@n
11  * http://www.tecgraf.puc-rio.br/~mgattass/color/ColorIndex.html @n
12  * Last retrieved 2009-07-30 @n
13  * @n
14  * License: @n
15  * @n
16  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @n
17  * @n
18  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @n
19  * @n
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * @authors Tim Place, Trond Lossius, Nils Peters, ...
23  *
24  * @copyright Copyright © 2007 by Tim Place @n
25  * This code is licensed under the terms of the "New BSD License" @n
26  * http://creativecommons.org/licenses/BSD/
27  */
28 
29 #ifndef __COLORDATASPACE_H__
30 #define __COLORDATASPACE_H__
31 
32 #include "TTDataspace.h"
33 
34 
35 /** Base class for the color dataspace, provides dataspace support for converting colors between CMY, HSL, HSV, RGB and RGB8.
36  *
37  * @details: RGB is the neutral data unit of this dataspace.
38  */
41 
42  /** Unit test for the color dataspace.
43  @param returnedTestInfo The outcome from the performed unit test.
44  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
45  */
46  virtual TTErr test(TTValue& returnedTestInfo);
47 };
48 
49 
50 /** Converts colors to and from CMY (Cyan - Magenta - Yellow).
51  *
52  * @details This unit is denoted as "cmy".
53  */
54 class CMYUnit : public TTDataObjectBase, public TTDataspaceUnit {
56 
57 public:
58 
59  /** Convert from CMY to neutral unit.
60  @param input Input color described using CMY .
61  @param output Returned color, converted to neutral unit.
62  */
63  void convertToNeutral(const TTValue& input, TTValue& output);
64 
65 
66  /** Convert from neutral unit to CMY.
67  @param input Input color described using the neutral unit.
68  @param output Returned color, described using CMY.
69  */
70  void convertFromNeutral(const TTValue& input, TTValue& output);
71 };
72 
73 
74 /** Converts colors to and from HSL (Hue - Saturation - Lighness).
75  *
76  * @details This unit is denoted as "hsl".
77  */
78 class HSLUnit : public TTDataObjectBase, public TTDataspaceUnit {
80 
81 public:
82 
83  /** Convert from HSL to neutral unit.
84  @param input Input color described using HSL .
85  @param output Returned color, converted to neutral unit.
86  */
87  void convertToNeutral(const TTValue& input, TTValue& output);
88 
89 
90  /** Convert from neutral unit to HSL.
91  @param input Input angle described using the neutral unit.
92  @param output Returned color, described using HSL.
93  */
94  void convertFromNeutral(const TTValue& input, TTValue& output);
95 };
96 
97 
98 /** Converts colors to and from HSV (Hue - Saturation - TODO: What is V?).
99  *
100  * @details This unit is denoted as "hsv".
101  */
102 class HSVUnit : public TTDataObjectBase, public TTDataspaceUnit {
104 
105 public:
106 
107  /** Convert from HSV to neutral unit.
108  @param input Input color described using HSV .
109  @param output Returned color, converted to neutral unit.
110  */
111  void convertToNeutral(const TTValue& input, TTValue& output);
112 
113 
114  /** Convert from neutral unit to HSV.
115  @param input Input color described using the neutral unit.
116  @param output Returned color, described using HSV.
117  */
118  void convertFromNeutral(const TTValue& input, TTValue& output);
119 };
120 
121 
122 /** Converts colors to and from RGB (Red - Green - Blue in the normalised [0, 1] range).
123  *
124  * @details This unit is denoted as "rgb".
125  */
126 class RGBUnit : public TTDataObjectBase, public TTDataspaceUnit {
128 
129 public:
130 
131  /** Convert from radians to neutral unit.
132  @param input Input color described using RGB .
133  @param output Returned color, converted to neutral unit.
134  */
135  void convertToNeutral(const TTValue& input, TTValue& output);
136 
137 
138  /** Convert from neutral unit to RGB.
139  @param input Input color described using the neutral unit.
140  @param output Returned color, described using RGB.
141  */
142  void convertFromNeutral(const TTValue& input, TTValue& output);
143 };
144 
145 
146 /** Converts colors to and from RGB8 (Red - Green - Blue in the 8-bit [0, 255] range).
147  *
148  * @details This unit is denoted as "rgb8".
149  */
150 class RGB8Unit : public TTDataObjectBase, public TTDataspaceUnit {
152 
153 public:
154 
155  /** Convert from RGB8 to neutral unit.
156  @param input Input color described using RGB8 .
157  @param output Returned color, converted to neutral unit.
158  */
159  void convertToNeutral(const TTValue& input, TTValue& output);
160 
161 
162  /** Convert from neutral unit to RGB8.
163  @param input Input color described using the neutral unit.
164  @param output Returned color, described using RGB8.
165  */
166  void convertFromNeutral(const TTValue& input, TTValue& output);
167 };
168 
169 
170 #endif // __COLORDATASPACE_H__
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from HSV to neutral unit.
Converts colors to and from CMY (Cyan - Magenta - Yellow).
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to HSL.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from radians to neutral unit.
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to RGB8.
TTDataObjectBase is the base class for all data generating and processing objects.
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from RGB8 to neutral unit.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to HSV.
Specification for the base class of each DataspaceUnit.
Converts colors to and from RGB8 (Red - Green - Blue in the 8-bit [0, 255] range).
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to CMY.
Converts colors to and from HSL (Hue - Saturation - Lighness).
Specification for TTDataspace, the base class of each dataspace.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
void convertFromNeutral(const TTValue &input, TTValue &output)
Convert from neutral unit to RGB.
Base class for each dataspace.
Definition: TTDataspace.h:30
Converts colors to and from HSV (Hue - Saturation - TODO: What is V?).
Base class for the color dataspace, provides dataspace support for converting colors between CMY...
Converts colors to and from RGB (Red - Green - Blue in the normalised [0, 1] range).
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from HSL to neutral unit.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
void convertToNeutral(const TTValue &input, TTValue &output)
Convert from CMY to neutral unit.