summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2012-06-02 10:44:24 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2012-06-02 10:44:24 +0200
commit41b1160f01b3435cd2c93de8874c5937c366d14f (patch)
treee2e51bbd959d4324e68f3618b0e9020d9a0ef109
parent5ee947a492cae5d917d95043a57a52261e45e0c1 (diff)
downloadvdr-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
-rw-r--r--HISTORY4
-rw-r--r--osd.c12
-rw-r--r--osd.h10
3 files changed, 23 insertions, 3 deletions
diff --git a/HISTORY b/HISTORY
index cccdc5be..fb78d903 100644
--- a/HISTORY
+++ b/HISTORY
@@ -7052,7 +7052,7 @@ Video Disk Recorder Revision History
- Fixed handling IDLEPRIORITY in cDvbDevice::ProvidesChannel() (thanks to Frank
Schmirler).
-2012-05-29: Version 1.7.28
+2012-06-02: Version 1.7.28
- Fixed cPixmapMemory::DrawEllipse() for quadrants -1 and -4.
- Fixed getting the maximum short channel name length in case there are no short names
@@ -7116,3 +7116,5 @@ Video Disk Recorder Revision History
to the recording's name.
- cVector::Clear() now reinitializes any previously used members.
- Fixed resetting CAMs (thanks to Marco Skambraks).
+- The new function RgbShade() (include osd.h) can be used to generate a brighter or
+ darker version of a given color.
diff --git a/osd.c b/osd.c
index 84c5a278..2edf4fae 100644
--- a/osd.c
+++ b/osd.c
@@ -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>)
diff --git a/osd.h b/osd.h
index 9f951bbb..06c020aa 100644
--- a/osd.h
+++ b/osd.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: osd.h 2.16 2012/05/17 15:09:35 kls Exp $
+ * $Id: osd.h 2.17 2012/06/02 10:32:38 kls Exp $
*/
#ifndef __OSD_H
@@ -70,6 +70,14 @@ inline tColor RgbToColor(double R, double G, double B)
return RgbToColor(uint8_t(0xFF * R), uint8_t(0xFF * G), uint8_t(0xFF * B));
}
+tColor RgbShade(tColor Color, double Factor);
+ ///< Returns a brighter (Factor > 0) or darker (Factor < 0) version
+ ///< of the given Color.
+ ///< If Factor is 0.0, the return value is the unchanged Color,
+ ///< If Factor is 1.0, white is returned.
+ ///< If Factor is -1.0, black is returned.
+ ///< The alpha value of Color is returned unchanged.
+
tColor HsvToColor(double H, double S, double V);
///< Converts the given Hue (0..360), Saturation (0..1) and Value (0..1)
///< to an RGB tColor value. The alpha value of the result is 0x00, so