11#include "../utility/utility.hpp"
12#include "../geometry/geometry.hpp"
13#include "color_intf.hpp"
14#include "../macros.hpp"
21hi_export_module(hikogui.color.sRGB);
26hi_warning_ignore_msvc(26426);
28hi_export
namespace hi {
inline namespace v1 {
34 matrix3{0.41239080f, 0.35758434f, 0.18048079f, 0.21263901f, 0.71516868f, 0.07219232f, 0.01933082f, 0.11919478f, 0.95053215f};
61 return 1.055f *
std::pow(
u, 0.416f) - 0.055f;
76 return std::pow((
u + 0.055f) / 1.055f, 2.4f);
86 for (
int i = 0; i != 65536; ++i) {
102 for (
int i = 0; i != 256; ++i) {
109hi_inline
auto sRGB_linear16_to_gamma8_table = sRGB_linear16_to_gamma8_table_generator();
110hi_inline
auto sRGB_gamma8_to_linear16_table = sRGB_gamma8_to_linear16_table_generator();
124 return detail::sRGB_linear16_to_gamma8_table[
u.intrinsic()];
137 return detail::sRGB_gamma8_to_linear16_table[
u];
165 return color_from_sRGB(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
172 if (
tmp.starts_with(
"#")) {
176 throw parse_error(std::format(
"Expecting 6 or 8 hex-digit sRGB color string, got {}.", str));
constexpr matrix3 XYZ_to_sRGB
Matrix to convert XYZ to sRGB.
Definition sRGB.hpp:39
hi_inline color color_from_sRGB(float r, float g, float b, float a) noexcept
Convert gama corrected sRGB color to the linear color.
Definition sRGB.hpp:149
hi_inline float sRGB_gamma_to_linear(float u) noexcept
sRGB gamma to linear transfer function.
Definition sRGB.hpp:71
hi_inline half sRGB_gamma8_to_linear16(uint8_t u) noexcept
sRGB gamma to linear float-16 transfer function.
Definition sRGB.hpp:135
hi_inline uint8_t sRGB_linear16_to_gamma8(half u) noexcept
sRGB linear float-16 to gamma transfer function.
Definition sRGB.hpp:122
constexpr matrix3 sRGB_to_XYZ
Matrix to convert sRGB to XYZ.
Definition sRGB.hpp:33
hi_inline float sRGB_linear_to_gamma(float u) noexcept
sRGB linear to gamma transfer function.
Definition sRGB.hpp:56
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
This is a RGBA floating point color.
Definition color_intf.hpp:49
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix3.hpp:36