Chromium Code Reviews| Index: ui/gfx/color_utils.cc |
| diff --git a/ui/gfx/color_utils.cc b/ui/gfx/color_utils.cc |
| index e35d7b33fb8dc8576969c3908e2da96541060f3a..27b8bea17cf500f5665222ad7317a32d5963f476 100644 |
| --- a/ui/gfx/color_utils.cc |
| +++ b/ui/gfx/color_utils.cc |
| @@ -11,6 +11,8 @@ |
| #include "base/logging.h" |
| #include "base/numerics/safe_conversions.h" |
| +#include "base/strings/string_number_conversions.h" |
| +#include "base/strings/stringprintf.h" |
| #include "build/build_config.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| #include "ui/gfx/color_palette.h" |
| @@ -347,4 +349,18 @@ SkColor DeriveDefaultIconColor(SkColor text_color) { |
| static_cast<int>(0.8f * SkColorGetA(text_color))); |
| } |
| +std::string SkColorToRGBAString(SkColor color) { |
| + // We convert the alpha using DoubleToString because StringPrintf will use |
| + // locale specific formatters (e.g., use , instead of . in German). |
| + return base::StringPrintf( |
| + "rgba(%d,%d,%d,%s)", SkColorGetR(color), SkColorGetG(color), |
|
msw
2017/02/28 22:43:15
optional nit: maybe it makes sense to compose SkCo
gonzalon
2017/03/02 15:43:08
Done.
|
| + SkColorGetB(color), |
| + base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); |
| +} |
| + |
| +std::string SkColorToRGBComponents(SkColor color) { |
|
msw
2017/02/28 22:43:15
You'll need to update this (cq dry run or local co
gonzalon
2017/03/02 15:43:08
Done.
|
| + return base::StringPrintf("%d,%d,%d", SkColorGetR(color), SkColorGetG(color), |
| + SkColorGetB(color)); |
| +} |
| + |
| } // namespace color_utils |