60 "image dimensions must be a multiple of {}, got {}x{}",
68 const std::size_t total_tiles = tiles_per_row * tiles_per_col;
70 std::vector<PixelTile<T>> tiles;
71 tiles.reserve(total_tiles);
74 for (std::size_t tile_row = 0; tile_row < tiles_per_col; ++tile_row) {
75 for (std::size_t tile_col = 0; tile_col < tiles_per_row; ++tile_col) {
85 const std::size_t src_row = pixel_row_offset + pixel_row;
86 const std::size_t src_col = pixel_col_offset + pixel_col;
88 tile.
set(pixel_row, pixel_col, img.
at(src_row, src_col));
92 tiles.push_back(std::move(tile));
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Service for converting images into collections of 8x8 tiles.
ChainableResult< std::vector< PixelTile< T > > > tileize(const Image< T > &img) const
Converts an image into a vector of 8x8 tiles.
A template for two-dimensional images with arbitrarily typed pixel values.
std::size_t width() const
Gets the width of this image in pixels.
PixelType at(std::size_t i) const
Fetches the pixel value at a given one-dimensional pixel index.
std::size_t height() const
Gets the height of this image in pixels.
An 8x8 tile backed by literal-array-based per-pixel storage of an arbitrary pixel type.
void set(std::size_t i, const PixelType &p)
constexpr std::size_t side_length_pix