From 880c6f67ca3637c54c97c51081e0649743292af3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 8 Nov 2016 13:22:45 +0000 Subject: [PATCH] Add Colour::to_rgb_string. --- src/types.cc | 11 +++++++++++ src/types.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/types.cc b/src/types.cc index 812e0f89..0347d02f 100644 --- a/src/types.cc +++ b/src/types.cc @@ -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. diff --git a/src/types.h b/src/types.h index dd2e10a6..e8761c81 100644 --- a/src/types.h +++ b/src/types.h @@ -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; }; -- 2.30.2