|
|
|
@ -4,12 +4,13 @@ |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <cassert> |
|
|
|
|
|
|
|
|
|
#include "Renderer.hpp" |
|
|
|
|
#define STB_IMAGE_WRITE_IMPLEMENTATION |
|
|
|
|
#include "stb_image_write.hpp" |
|
|
|
|
#include <stb_image_write.hpp> |
|
|
|
|
|
|
|
|
|
#include "util.hpp" |
|
|
|
|
#include "Renderer.hpp" |
|
|
|
|
|
|
|
|
|
namespace massivedynamic { |
|
|
|
|
typedef uint32_t Color; |
|
|
|
|
|
|
|
|
|
class PixelRenderer : public Renderer { |
|
|
|
|
protected: |
|
|
|
@ -37,13 +38,11 @@ namespace massivedynamic { |
|
|
|
|
WHITE = 0xFFFFFFFF |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
PixelRenderer(const std::vector<bool>& pixels, size_t sourceSize, size_t targetSize) : Renderer(pixels, sourceSize, targetSize), pixelSize(0) { |
|
|
|
|
this->targetSize = this->targetSize == 0 ? (sourceSize + 2) * 2 : this->targetSize; |
|
|
|
|
this->pixelSize = round(static_cast<float>(this->targetSize) / static_cast<float>(this->sourceSize + 2)); |
|
|
|
|
this->border = round(static_cast<float>(this->targetSize - this->pixelSize * this->sourceSize) / 2.0f); |
|
|
|
|
|
|
|
|
|
this->bitmap = std::vector<Color>(this->targetSize * this->targetSize, Colors::WHITE); |
|
|
|
|
} |
|
|
|
|
PixelRenderer(const std::vector<bool>& pixels, size_t sourceSize, size_t targetSize) : |
|
|
|
|
Renderer(pixels, sourceSize, targetSize == 0 ? (sourceSize + 2) * 2 : targetSize), |
|
|
|
|
pixelSize(round(static_cast<float>(this->targetSize) / static_cast<float>(this->sourceSize + 2))), |
|
|
|
|
border(round(static_cast<float>(this->targetSize - this->pixelSize * this->sourceSize) / 2.0f)), |
|
|
|
|
bitmap(std::vector<Color>(this->targetSize * this->targetSize, Colors::WHITE)) {} |
|
|
|
|
|
|
|
|
|
virtual void generateBuffer() { |
|
|
|
|
for (size_t y = 0; y < sourceSize; y++) { |
|
|
|
|