2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
20 * @brief This is the implementation file for Color class.
22 * This file contains implementation of Color class.
26 #include <FGrpColor.h>
29 namespace Tizen { namespace Graphics
38 Color::Color(const Color& rhs)
42 __color = rhs.GetRGB32();
45 Color::Color(byte red, byte green, byte blue, byte alpha)
49 SetColorComponents(red, green, blue, alpha);
52 Color::Color(unsigned int rgb, bool hasAlpha)
55 SetRGB32(rgb, hasAlpha);
63 Color::operator ==(const Color& rhs) const
65 return (__color == rhs.__color);
69 Color::operator !=(const Color& rhs) const
71 return (!operator ==(rhs));
75 Color::operator =(const Color& rhs)
82 __color = rhs.GetRGB32();
88 Color::Equals(const Tizen::Base::Object& rhs) const
95 const Color* pColor = dynamic_cast <const Color*>(&rhs);
102 return (*this == *pColor);
106 Color::GetHashCode(void) const
112 Color::GetAlpha(void) const
114 return byte((__color >> 24) & 0xFF);
118 Color::GetRed(void) const
120 return byte((__color >> 16) & 0xFF);
124 Color::GetGreen(void) const
126 return byte((__color >> 8) & 0xFF);
130 Color::GetBlue(void) const
132 return byte((__color >> 0) & 0xFF);
136 Color::GetColorComponents(byte& red, byte& green, byte& blue, byte& alpha) const
145 Color::GetRGB32(void) const
151 Color::SetAlpha(byte alpha)
153 __color &= (0x00FFFFFF);
154 __color |= ((alpha & 0xFF) << 24);
158 Color::SetRed(byte red)
160 __color &= (0xFF00FFFF);
161 __color |= ((red & 0xFF) << 16);
165 Color::SetGreen(byte green)
167 __color &= (0xFFFF00FF);
168 __color |= ((green & 0xFF) << 8);
172 Color::SetBlue(byte blue)
174 __color &= (0xFFFFFF00);
175 __color |= ((blue & 0xFF) << 0);
179 Color::SetColorComponents(byte red, byte green, byte blue, byte alpha)
188 Color::SetRGB32(unsigned int rgb, bool hasAlpha)
190 __color = ((hasAlpha ? rgb : (0xFF000000 | rgb)));
194 Color::GetColor(ColorId colorId)
196 Color color(0xFF000000);
201 color.SetRGB32(0xFF000000);
204 color.SetRGB32(0xFF0000FF);
207 color.SetRGB32(0xFF00FFFF);
210 color.SetRGB32(0xFF00FF00);
213 color.SetRGB32(0xFFC0C0C0);
215 case COLOR_ID_MAGENTA:
216 color.SetRGB32(0xFFFF00FF);
219 color.SetRGB32(0xFFFF0000);
221 case COLOR_ID_VIOLET:
222 color.SetRGB32(0xFF4F2F4F);
224 case COLOR_ID_YELLOW:
225 color.SetRGB32(0xFFFFFF00);
228 color.SetRGB32(0xFFFFFFFF);
235 }} // Tizen::Graphics