summaryrefslogtreecommitdiff
path: root/src/colour.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-07-02 13:21:16 +0100
committerCarl Hetherington <cth@carlh.net>2015-07-02 13:21:16 +0100
commit4d406c620b0211a5e27c19187d963241120f8838 (patch)
tree4ec7f4a1652ee89fc1b45faccb4d2d72a512a698 /src/colour.cc
parentb20c6fd0047a7b8ad63d19c46c3ea0e2185babc2 (diff)
Add support for reading <font> tags in SubRip.
Diffstat (limited to 'src/colour.cc')
-rw-r--r--src/colour.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/colour.cc b/src/colour.cc
index f163424..a47e633 100644
--- a/src/colour.cc
+++ b/src/colour.cc
@@ -25,16 +25,26 @@
using std::string;
using namespace sub;
-Colour::Colour (string argb_hex)
+Colour
+Colour::from_argb_hex (string argb_hex)
{
int alpha, ir, ig, ib;
if (sscanf (argb_hex.c_str(), "%2x%2x%2x%2x", &alpha, &ir, &ig, &ib) < 4) {
throw XMLError ("could not parse colour string");
}
- r = float (ir) / 255;
- g = float (ig) / 255;
- b = float (ib) / 255;
+ return Colour (float (ir) / 255, float (ig) / 255, float (ib) / 255);
+}
+
+Colour
+Colour::from_rgb_hex (string rgb_hex)
+{
+ int ir, ig, ib;
+ if (sscanf (rgb_hex.c_str(), "%2x%2x%2x", &ir, &ig, &ib) < 3) {
+ throw XMLError ("could not parse colour string");
+ }
+
+ return Colour (float (ir) / 255, float (ig) / 255, float (ib) / 255);
}
bool