1#ifndef TATOOINE_WRITE_PNG_H
2#define TATOOINE_WRITE_PNG_H
11#if TATOOINE_PNG_AVAILABLE
12template <arithmetic T>
14 std::vector<T>
const& data, std::size_t width, std::size_t height) {
15 auto image = png::image<png::rgb_pixel>{
static_cast<png::uint_32
>(width),
16 static_cast<png::uint_32
>(height)};
17 for (png::uint_32 y = 0; y < image.get_height(); ++y) {
18 for (png::uint_32 x = 0; x < image.get_width(); ++x) {
19 auto idx = x +
static_cast<png::uint_32
>(width) * y;
24 d = std::clamp(d, T(0), T(1));
26 image[image.get_height() - 1 - y][x].red =
27 image[image.get_height() - 1 - y][x].green =
28 image[image.get_height() - 1 - y][x].blue = d * 255;
31 image.write(path.string());
Definition: algorithm.h:6
void write_png(filesystem::path const &path, std::vector< T > const &data, std::size_t width, std::size_t height)
Definition: write_png.h:13