|
Orrery
A GPU-accelerated N-body gravitational simulator
|
A rectangle of 8-bit RGB pixels, row-major from the top left. More...
#include <orrery/viz/image.hpp>
Public Member Functions | |
| Image (std::size_t width, std::size_t height) | |
| A black image of the given size. | |
| std::size_t | width () const noexcept |
| std::size_t | height () const noexcept |
| std::span< const std::uint8_t > | pixels () const noexcept |
| The pixel bytes, width * height * kChannels of them. | |
| std::span< std::uint8_t > | pixels () noexcept |
| 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. | |
| void | write_ppm (const std::filesystem::path &path) const |
| Write the image as binary PPM. | |
Static Public Attributes | |
| static constexpr std::size_t | kChannels = 3 |
| The number of bytes one pixel occupies. | |
A rectangle of 8-bit RGB pixels, row-major from the top left.
|
noexcept |
Write one pixel, with y counted from the top.
Out-of-range coordinates are ignored rather than checked by assertion. The only callers are loops over the image's own dimensions, and a silent no-op is a better failure than a crash in a viewer that is midway through exporting four thousand frames.
| void orrery::viz::Image::write_ppm | ( | const std::filesystem::path & | path | ) | const |
Write the image as binary PPM.
Throws std::runtime_error if the file cannot be opened or the write fails. An export writes one of these per frame, and a disc that fills halfway through should stop the export rather than produce a video with a hole in it.
|
staticconstexpr |
The number of bytes one pixel occupies.
Three: red, green and blue, with no alpha, because a frame of a video has nothing to be transparent against.