SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
color_tools.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4#pragma once
5//
6#include <array>
7#include <string>
8#include "slideio/core/slideio_core_def.hpp"
9
10namespace slideio {
14 enum class HexColorFormat {
15 UNKNOWN,
16 RGB, // #RRGGBB (6 hex digits)
17 RGBA, // #RRGGBBAA (8 hex digits, standard web format)
18 ARGB // #AARRGGBB (8 hex digits, OME-TIFF format)
19 };
20
21 class SLIDEIO_CORE_EXPORTS ColorTools {
22 public:
23 static HexColorFormat detectHexColorFormat(const std::string& hexColor);
24 static std::string HexColorFormatToString(HexColorFormat format);
25 static std::array<uint8_t, 4> hexARGBToRGBA(const std::string& hexColor);
26 static std::array<uint8_t, 4> hexRGBAToRGBA(const std::string& hexColor);
27 static std::array<uint8_t, 4> hexToRGBA(const std::string& hexColor, uint8_t defaultAlpha = 0);
28 static std::array<uint8_t, 3> RGBAToRGB(const std::array<uint8_t, 4>& rgba);
29 static std::string RGBAToHexARGB(const std::array<uint8_t, 4>& rgba);
30 static std::array<uint8_t, 4> smartHexToRGBA(const std::string& hexColor, uint8_t defaultAlpha = 0);
31 static std::string RGBAToHexRGBA(const std::array<uint8_t, 4>& rgba);
32 static std::string hexToInt32String(const std::string& hexColor);
33 static std::string rgbaInt32StringToHexARGB(const std::string& value);
34 static std::string rgbCsvToHexRGB(const std::string& csv);
35 };
36}
Definition: exceptions.hpp:15
HexColorFormat
Definition: color_tools.hpp:14