diff options
author | Aleksey Lim <alsroot@member.fsf.org> | 2009-02-19 06:34:10 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@member.fsf.org> | 2009-02-20 00:03:07 (GMT) |
commit | 3bf19ed84024bf7005e3fe6639d3394405df4867 (patch) | |
tree | 05f22b775967ba191e8aee62278d805811a82457 /colorsc/colorsc.h | |
parent | 1c66573c30e9ebec4ad78dab282c702de12f9552 (diff) |
Support 24/32 screen depths in color picker; optimization
Diffstat (limited to 'colorsc/colorsc.h')
-rw-r--r-- | colorsc/colorsc.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/colorsc/colorsc.h b/colorsc/colorsc.h index 2e4c372..7e4c1fa 100644 --- a/colorsc/colorsc.h +++ b/colorsc/colorsc.h @@ -27,6 +27,9 @@ using namespace std; #include <cmath> #include <float.h> +typedef guint16 depth16_t; +typedef guint32 depth24_t; + static const float PI = 3.14159f; inline float sgn(float a) { if (a>0) return 1; if (a<0) return -1; return 0; } @@ -107,6 +110,17 @@ struct Color return c; } unsigned int get_r5g6b5() { return ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); } + + void to_pixel(depth16_t *pixel) + { + *pixel = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); + } + + void to_pixel(depth24_t *pixel) + { + *pixel = (r<<16) | (g<<8) | b; + } + static Color create_from_r5g6b5(unsigned short v) { Color c; |