26 #include "lv_common.h"
30 #if VISUAL_LITTLE_ENDIAN == 1
31 uint16_t b:5, g:6, r:5;
33 uint16_t r:5, g:6, b:5;
45 float f, w, q, t,
r = 0,
g = 0,
b = 0;
57 q = v * (1.0 - (s * f));
58 t = v * (1.0 - (s * (1.0 - f)));
61 case 0: r = v;
g = t;
b = w;
break;
62 case 1: r = q;
g = v;
b = w;
break;
63 case 2: r = w;
g = v;
b = t;
break;
64 case 3: r = w;
g = q;
b = v;
break;
65 case 4: r = t;
g = w;
b = v;
break;
66 case 5: r = v;
g = w;
b = q;
break;
72 set (r * 255,
g * 255,
b * 255);
100 s = (max - min) / max;
107 float delta = max - min;
110 h = (gf - bf) / delta;
112 h = 2.0 + (bf - rf) / delta;
114 h = 4.0 + (rf - gf) / delta;
123 void Color::set_from_uint32 (uint32_t rgba)
125 auto const color =
reinterpret_cast<uint8_t*
> (&rgba);
127 #if VISUAL_LITTLE_ENDIAN == 1
137 #endif // VISUAL_LITTLE_ENDIAN
140 void Color::set_from_uint16 (uint16_t rgb)
145 r = pixel.rgb.r << 3;
146 g = pixel.rgb.g << 2;
147 b = pixel.rgb.b << 3;
150 uint32_t Color::to_uint32 ()
const
152 return ( (
a << 24) | (
r << 16) | (
g << 8) |
b );
155 uint16_t Color::to_uint16 ()
const
159 pixel.rgb.r =
r >> 3;
160 pixel.rgb.g =
g >> 2;
161 pixel.rgb.b =
b >> 3;