diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-01-31 23:24:45 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-01-31 23:24:45 +0100 |
| commit | cd8ae0e4f628bd491fcaf1dd4778bc283d619065 (patch) | |
| tree | dea35210e2bfe21182cfec76511a84de9a23a2fa /lib/nes/app/graphics/image-view.hh | |
| parent | 307e07d6513f9524b7fcab5134494bd175465cd1 (diff) | |
implement renderer
Diffstat (limited to 'lib/nes/app/graphics/image-view.hh')
| -rw-r--r-- | lib/nes/app/graphics/image-view.hh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/nes/app/graphics/image-view.hh b/lib/nes/app/graphics/image-view.hh new file mode 100644 index 0000000..a9b8e94 --- /dev/null +++ b/lib/nes/app/graphics/image-view.hh @@ -0,0 +1,31 @@ +#pragma once + +namespace nes::app +{ + struct image_tile; + + /// Non-owning copy of a 2-dimensional block of image tiles, forming an image. + /// + /// This is similar in spirit to a string_view, but for image tiles. + class image_view + { + image_tile const* data_{ nullptr }; + unsigned width_{ 0 }; + unsigned height_{ 0 }; + + public: + explicit image_view() = default; + + explicit image_view(image_tile const* data, unsigned const width, unsigned const height) + : data_{ data } + , width_{ width } + , height_{ height } + { + } + + auto get_data() const -> image_tile const* { return data_; } + auto get_width() const -> unsigned { return width_; } + auto get_height() const -> unsigned { return height_; } + auto get(unsigned const x, unsigned const y) const -> image_tile const& { return data_[y * height_ + x]; } + }; +} // namespace nes::app
\ No newline at end of file |
