diff options
| author | Mel <einebeere@gmail.com> | 2023-07-07 23:05:14 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-07-07 23:14:59 +0200 |
| commit | 129f2e421e16bd008cdca8713cc91f67d103d94e (patch) | |
| tree | a4d3e1005c57591b44fd57be4c1b00441512e36d /src/GFX/Image/RawImage.cpp | |
| parent | f1fc192ddc4c739fa8b4b376c759b7d3218a34eb (diff) | |
| download | meowcraft-129f2e421e16bd008cdca8713cc91f67d103d94e.tar.zst meowcraft-129f2e421e16bd008cdca8713cc91f67d103d94e.zip | |
Fix minor quality issues
Diffstat (limited to 'src/GFX/Image/RawImage.cpp')
| -rw-r--r-- | src/GFX/Image/RawImage.cpp | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/src/GFX/Image/RawImage.cpp b/src/GFX/Image/RawImage.cpp index 1222fab..6cb06b2 100644 --- a/src/GFX/Image/RawImage.cpp +++ b/src/GFX/Image/RawImage.cpp @@ -1,21 +1,9 @@ #include "RawImage.hpp" +#include <sstream> namespace MC::GFX::Image { -RawImage::RawImage(Util::Sampler<2, float>& sampler, uint32_t width, uint32_t height) - : m_pixels(), m_width(width), m_height(height) -{ - m_pixels.reserve(width * height); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - auto result = sampler.sample({(float)x, (float)y}); - auto intensity = (uint8_t)(result * 255); - add({intensity, intensity, intensity}); - } - } -} - -void RawImage::add(RawImage::Pixel pixel) { +void RawImage::add(Pixel pixel) { m_pixels.push_back(pixel); } @@ -35,18 +23,14 @@ uint32_t RawImage::height() const { return m_height; } -uint8_t RawImage::channels() const { - return m_channels; -} - std::string RawImage::string() const { std::stringstream str{}; bool comma = false; str << "["; - for (const auto& pixel : m_pixels) { + for (const auto [r, g, b] : m_pixels) { if (comma) { str << ", "; } - str << "{r=" << (uint)pixel.r << ", g=" << (uint)pixel.g << ", b=" << (uint)pixel.r << "}"; + str << "{r=" << (uint)r << ", g=" << (uint)g << ", b=" << (uint)r << "}"; comma = true; } str << "]"; |
