diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2012-06-02 10:44:24 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2012-06-02 10:44:24 +0200 |
commit | 41b1160f01b3435cd2c93de8874c5937c366d14f (patch) | |
tree | e2e51bbd959d4324e68f3618b0e9020d9a0ef109 /osd.c | |
parent | 5ee947a492cae5d917d95043a57a52261e45e0c1 (diff) | |
download | vdr-41b1160f01b3435cd2c93de8874c5937c366d14f.tar.gz vdr-41b1160f01b3435cd2c93de8874c5937c366d14f.tar.bz2 |
The new function RgbShade() (include osd.h) can be used to generate a brighter or darker version of a given color
Diffstat (limited to 'osd.c')
-rw-r--r-- | osd.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.c 2.29 2012/05/17 13:29:19 kls Exp $ + * $Id: osd.c 2.30 2012/06/02 10:42:23 kls Exp $ */ #include "osd.h" @@ -40,6 +40,16 @@ tColor HsvToColor(double H, double S, double V) } } +tColor RgbShade(tColor Color, double Factor) +{ + double f = fabs(constrain(Factor, -1.0, 1.0)); + double w = Factor > 0 ? f * 0xFF : 0; + return (Color & 0xFF000000) | + (min(0xFF, int((1 - f) * ((Color >> 16) & 0xFF) + w + 0.5)) << 16) | + (min(0xFF, int((1 - f) * ((Color >> 8) & 0xFF) + w + 0.5)) << 8) | + (min(0xFF, int((1 - f) * ( Color & 0xFF) + w + 0.5)) ); +} + #define USE_ALPHA_LUT #ifdef USE_ALPHA_LUT // Alpha blending with lookup table (by Reinhard Nissl <rnissl@gmx.de>) |