diff --git a/RayTracer/sampling/Image.cpp b/RayTracer/sampling/Image.cpp index 696c1023596d0145a6964d0b3615716a76cebce0..09d0930d9b2bbadfa5307e368ba92667d36680de 100644 --- a/RayTracer/sampling/Image.cpp +++ b/RayTracer/sampling/Image.cpp @@ -1,5 +1,6 @@ #include "Image.h" +#include "../tools/Threadpool.h" #include "StratifiedSampler.h" namespace util { @@ -9,10 +10,13 @@ Image::Image(int width, int height) : width(width), height(height) { vec.insert(vec.end(), color); } } +void Image::setPixel(int x, int y, Vec3 color) { + vec[width * y + x] = color; +} void Image::setPixels(std::shared_ptr<Sampler> sampler) { for (int x = 0; x != width; x++) { for (int y = 0; y != height; y++) { - vec[width * y + x] = sampler->color(x, y); + setPixel(x, y, sampler->color(x, y)); } } } diff --git a/RayTracer/sampling/Image.h b/RayTracer/sampling/Image.h index 1c783ddc4b593b9f981075a91637cad8c135cdbc..673026d84b1dbd9c32fc2d88c2d6e5aac1851579 100644 --- a/RayTracer/sampling/Image.h +++ b/RayTracer/sampling/Image.h @@ -11,6 +11,7 @@ class Image { public: Image(int width, int height); + void setPixel(int x, int y, Vec3 color); void setPixels(std::shared_ptr<Sampler> sampler); Vec3 operator[](const std::array<int, 2>& i) const; // int x, int y @@ -20,7 +21,7 @@ class Image { const int height; private: - std::vector<util::Vec3> vec; + std::vector<Vec3> vec; }; Image raytrace(const cam::CamObs& cam, const std::shared_ptr<Sampler>& sampler,