npapi-vlc | branch: master | Cheng Sun <[email protected]> | Sat Jan 14 
21:21:36 2012 +0700| [d027aa4d5a527e84138bc1d5b4fd9e4d492b268a] | committer: 
Cheng Sun

Added common HTMLColor2RGB utility function to parse #rgb and #rrggbb color 
strings

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=d027aa4d5a527e84138bc1d5b4fd9e4d492b268a
---

 common/vlc_player_options.h |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/common/vlc_player_options.h b/common/vlc_player_options.h
index 431e42f..6fee5e4 100644
--- a/common/vlc_player_options.h
+++ b/common/vlc_player_options.h
@@ -23,6 +23,30 @@
 #define _VLC_PLAYER_OPTIONS_H_
 
 #include <string>
+#include <cstring>
+#include <cstdio>
+
+static bool HTMLColor2RGB(const char *htmlColor, uint8_t *r, uint8_t *g, 
uint8_t *b)
+{
+    if (!htmlColor)
+        return false;
+    switch (strlen(htmlColor)) {
+        case 4:
+            if (sscanf(htmlColor, "#%1x%1x%1x", r, g, b) != 3)
+                return false;
+            *r *= 0x11;
+            *g *= 0x11;
+            *b *= 0x11;
+            return true;
+        case 7:
+            if (sscanf(htmlColor, "#%2x%2x%2x", r, g, b) != 3)
+                return false;
+            return true;
+        default:
+            return false;
+    }
+}
+
 
 enum vlc_player_option_e
 {

_______________________________________________
vlc-commits mailing list
[email protected]
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to