Add Colour::to_rgb_string.
authorCarl Hetherington <cth@carlh.net>
Tue, 8 Nov 2016 13:22:45 +0000 (13:22 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 8 Nov 2016 13:22:45 +0000 (13:22 +0000)
src/types.cc
src/types.h

index 812e0f8986275182695e216085ba771d0f531fda..0347d02f15cc7f68df9f67f4cf282682f1f3cebf 100644 (file)
@@ -126,6 +126,17 @@ Colour::to_argb_string () const
        return buffer;
 }
 
+/** @return An RGB string of the form RRGGBB, where e.g. RR is a two-character
+ *  hex value.
+ */
+string
+Colour::to_rgb_string () const
+{
+       char buffer[7];
+       snprintf (buffer, sizeof(buffer), "%02X%02X%02X", r, g, b);
+       return buffer;
+}
+
 /** operator== for Colours.
  *  @param a First colour to compare.
  *  @param b Second colour to compare.
index dd2e10a6f4cc29d44d4421d166af2cd0d404dc56..e8761c816e08c2df25ca6c2ffdafe76c422ad602 100644 (file)
@@ -246,6 +246,7 @@ public:
        int g; ///< green component, from 0 to 255
        int b; ///< blue component, from 0 to 255
 
+       std::string to_rgb_string () const;
        std::string to_argb_string () const;
 };