Add sRGB <-> linear conversion for pixmaps

This commit is contained in:
Nikita Lisitsa 2022-05-16 23:25:34 +03:00
parent 565ab68682
commit a3d5a424dd

View file

@ -27,4 +27,18 @@ namespace psemek::gfx
pixmap_rgba read_png(io::istream && is);
pixmap_monochrome read_png_monochrome(io::istream && is);
template <typename Pixel, std::size_t N>
auto to_srgb(util::array<Pixel, N> pm, float g = 1.f / 2.2f)
{
for (auto & c : pm)
c = to_srgb(c, g);
return pm;
}
template <typename Pixel, std::size_t N>
auto to_linear(util::array<Pixel, N> pm, float g = 1.f / 2.2f)
{
return to_srgb(std::move(pm), 1.f / g);
}
}