Orrery
A GPU-accelerated N-body gravitational simulator
Toggle main menu visibility
Loading...
Searching...
No Matches
image.hpp
Go to the documentation of this file.
1
#pragma once
2
23
24
#include <cstddef>
25
#include <cstdint>
26
#include <filesystem>
27
#include <span>
28
#include <vector>
29
30
#include "
orrery/viz/tone_map.hpp
"
31
32
namespace
orrery::viz {
33
35
class
Image {
36
public
:
40
static
constexpr
std::size_t
kChannels
= 3;
41
42
Image() =
default
;
43
45
Image
(std::size_t width, std::size_t height);
46
47
[[nodiscard]] std::size_t width() const noexcept {
return
width_; }
48
49
[[nodiscard]] std::size_t height() const noexcept {
return
height_; }
50
52
[[nodiscard]] std::span<const std::uint8_t>
pixels
() const noexcept {
return
pixels_; }
53
54
[[nodiscard]] std::span<std::uint8_t>
pixels
() noexcept {
return
pixels_; }
55
62
void
set
(std::size_t x, std::size_t y, std::uint8_t red, std::uint8_t green,
63
std::uint8_t blue)
noexcept
;
64
71
void
write_ppm
(
const
std::filesystem::path& path)
const
;
72
73
private
:
74
std::size_t width_ = 0;
75
std::size_t height_ = 0;
76
std::vector<std::uint8_t> pixels_;
77
};
78
89
void
tone_map_into
(
Image
& image, std::span<const float> radiance,
ToneMapping
mapping,
90
bool
bottom_up);
91
92
}
// namespace orrery::viz
orrery::viz::Image
A rectangle of 8-bit RGB pixels, row-major from the top left.
Definition
image.hpp:35
orrery::viz::Image::kChannels
static constexpr std::size_t kChannels
The number of bytes one pixel occupies.
Definition
image.hpp:40
orrery::viz::Image::pixels
std::span< const std::uint8_t > pixels() const noexcept
The pixel bytes, width * height * kChannels of them.
Definition
image.hpp:52
orrery::viz::Image::set
void set(std::size_t x, std::size_t y, std::uint8_t red, std::uint8_t green, std::uint8_t blue) noexcept
Write one pixel, with y counted from the top.
orrery::viz::Image::Image
Image(std::size_t width, std::size_t height)
A black image of the given size.
orrery::viz::Image::write_ppm
void write_ppm(const std::filesystem::path &path) const
Write the image as binary PPM.
orrery::viz::tone_map_into
void tone_map_into(Image &image, std::span< const float > radiance, ToneMapping mapping, bool bottom_up)
Fill image from a buffer of linear radiance, three floats per pixel.
orrery::viz::ToneMapping
The two numbers that decide how bright the picture is.
Definition
tone_map.hpp:56
tone_map.hpp
Turning accumulated light into pixels.
orrery
viz
image.hpp
Generated by
1.17.0