IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
peak_icv_color.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <peak_common_c/detail/peak_common_defines.h>
14#include <peak_icv_c/painting/peak_icv_painter.h>
15
16#include <tuple>
17
18namespace peak
19{
20namespace icv
21{
22
30using red_t = uint16_t;
38using green_t = uint16_t;
46using blue_t = uint16_t;
47
57enum class ColorConstant : uint64_t
58{
64 Black = PEAK_ICV_COLOR_BLACK,
70 Red = PEAK_ICV_COLOR_RED,
76 Red8 = PEAK_ICV_COLOR_RED_8,
82 Red10 = PEAK_ICV_COLOR_RED_10,
88 Red12 = PEAK_ICV_COLOR_RED_12,
94 Green = PEAK_ICV_COLOR_GREEN,
100 Green8 = PEAK_ICV_COLOR_GREEN_8,
106 Green10 = PEAK_ICV_COLOR_GREEN_10,
112 Green12 = PEAK_ICV_COLOR_GREEN_12,
118 Blue = PEAK_ICV_COLOR_BLUE,
124 Blue8 = PEAK_ICV_COLOR_BLUE_8,
130 Blue10 = PEAK_ICV_COLOR_BLUE_10,
136 Blue12 = PEAK_ICV_COLOR_BLUE_12
137};
138
146class Color
147{
148public:
154 constexpr Color() = default;
155
168 constexpr explicit Color(uint64_t colorCodeRaw)
169 : m_colorCode{ colorCodeRaw }
170 {}
171
181 constexpr Color(uint16_t red, uint16_t green, uint16_t blue)
182 : Color(PEAK_ICV_COLOR_CODE(red, green, blue))
183 {}
184
195 constexpr Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t numBitsPerPixels)
196 : Color(PEAK_ICV_COLOR_CODE(red * ((1 << numBitsPerPixels) - 1) / 255, green * ((1 << numBitsPerPixels) - 1) / 255,
197 blue * ((1 << numBitsPerPixels) - 1) / 255))
198 {}
199
207 constexpr explicit Color(ColorConstant colorCode)
208 : m_colorCode{ static_cast<uint64_t>(colorCode) }
209 {}
210
216 PEAK_COMMON_NO_DISCARD constexpr uint16_t GetRed() const
217 {
218 return static_cast<uint16_t>(PEAK_ICV_COLOR_RED_FROM_CODE(m_colorCode));
219 }
220
226 PEAK_COMMON_NO_DISCARD constexpr uint16_t GetGreen() const
227 {
228 return static_cast<uint16_t>(PEAK_ICV_COLOR_GREEN_FROM_CODE(m_colorCode));
229 }
230
236 PEAK_COMMON_NO_DISCARD constexpr uint16_t GetBlue() const
237 {
238 return static_cast<uint16_t>(PEAK_ICV_COLOR_BLUE_FROM_CODE(m_colorCode));
239 }
240
246 PEAK_COMMON_NO_DISCARD constexpr std::tuple<red_t, green_t, blue_t> GetRGB() const
247 {
248 return std::make_tuple(GetRed(), GetGreen(), GetBlue());
249 }
250
256 PEAK_COMMON_NO_DISCARD constexpr uint64_t GetRaw() const
257 {
258 return m_colorCode;
259 }
260
266 constexpr bool operator==(const Color& rhs) const
267 {
268 return m_colorCode == rhs.m_colorCode;
269 }
270
276 constexpr bool operator!=(const Color& rhs) const
277 {
278 return !(rhs == *this);
279 }
280
286 constexpr bool operator==(const ColorConstant& rhs) const
287 {
288 return m_colorCode == static_cast<uint64_t>(rhs);
289 }
290
296 constexpr bool operator!=(const ColorConstant& rhs) const
297 {
298 return !(*this == rhs);
299 }
300
301private:
302 uint64_t m_colorCode{};
303};
304
305} /* namespace icv */
306} /* namespace peak */
Holds a color code composed of red, green, and blue components.
constexpr uint16_t GetGreen() const
constexpr uint16_t GetRed() const
constexpr Color(uint16_t red, uint16_t green, uint16_t blue)
Constructs a Color from separate red, green, and blue values.
constexpr Color(ColorConstant colorCode)
Constructs a Color from a predefined ColorConstant.
constexpr uint64_t GetRaw() const
constexpr Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t numBitsPerPixels)
Constructs a Color from separate red, green, and blue values.
constexpr bool operator!=(const ColorConstant &rhs) const
constexpr std::tuple< red_t, green_t, blue_t > GetRGB() const
constexpr bool operator==(const ColorConstant &rhs) const
constexpr uint16_t GetBlue() const
constexpr bool operator!=(const Color &rhs) const
constexpr bool operator==(const Color &rhs) const
constexpr Color()=default
Constructs a default Color initialized to black.
constexpr Color(uint64_t colorCodeRaw)
Constructs a Color from a raw 64-bit color code containing RGB values.
uint16_t red_t
Represents the red component of a color.
uint16_t green_t
Represents the green component of a color.
ColorConstant
Represents predefined color constants.
uint16_t blue_t
Represents the blue component of a color.
@ Green8
Represents green with 8-bit intensity.
@ Blue8
Represents blue with 8-bit intensity.
@ Green10
Represents green with 10-bit intensity.
@ Red10
Represents red with 10-bit intensity.
@ Blue12
Represents blue with 12-bit intensity.
@ Red8
Represents red with 8-bit intensity.
@ Green12
Represents green with 12-bit intensity.
@ Blue
Represents blue with 8-bit intensity.
@ Red12
Represents red with 12-bit intensity.
@ Blue10
Represents blue with 10-bit intensity.
@ Green
Represents green with 8-bit intensity.
@ Black
Represents black with 8-bit intensity.
@ Red
Represents red with 8-bit intensity.