COSC-3P93-Project/Step 3/include/engine/image/image.h

71 lines
2.1 KiB
C
Raw Normal View History

2022-10-20 11:30:15 -04:00
/*
* Created by Brett Terpstra 6920201 on 14/10/22.
* Copyright (c) Brett Terpstra 2022 All Rights Reserved
*/
#ifndef STEP_2_IMAGE_H
#define STEP_2_IMAGE_H
#include "engine/util/std.h"
#include "engine/math/vectors.h"
2022-10-20 11:30:15 -04:00
namespace Raytracing {
// glorified structure to store our image data.
class Image {
private:
2022-10-25 01:06:26 -04:00
unsigned long width;
unsigned long height;
unsigned long _width;
unsigned long _height;
2022-10-20 11:30:15 -04:00
Vec4 *pixelData;
public:
2022-10-25 01:06:26 -04:00
Image(unsigned long width, unsigned long height);
2022-10-20 11:30:15 -04:00
Image(const Image &image);
Image(const Image&& image) = delete;
2022-10-25 01:06:26 -04:00
inline void setPixelColor(unsigned long x, unsigned long y, const Vec4 &color) {
2022-10-20 11:30:15 -04:00
pixelData[(x * height) + y] = color;
}
2022-10-25 01:06:26 -04:00
[[nodiscard]] inline Vec4 getPixelColor(unsigned long x, unsigned long y) const {
2022-10-20 11:30:15 -04:00
return pixelData[(x * height) + y];
}
[[nodiscard]] int getPixelR(int x, int y) const;
[[nodiscard]] int getPixelG(int x, int y) const;
[[nodiscard]] int getPixelB(int x, int y) const;
[[nodiscard]] int getPixelA(int x, int y) const;
2022-10-25 01:06:26 -04:00
[[nodiscard]] inline int getWidth() const { return int(width); }
2022-10-20 11:30:15 -04:00
2022-10-25 01:06:26 -04:00
[[nodiscard]] inline int getHeight() const { return int(height); }
2022-10-20 11:30:15 -04:00
~Image();
};
class ImageInput {
private:
int width, height, channels;
unsigned char* data;
public:
explicit ImageInput(const std::string& image);
unsigned long* getImageAsIconBuffer();
unsigned char* getImageData(){return data;}
[[nodiscard]] int getImageSize() const{return width;}
~ImageInput();
};
2022-10-20 11:30:15 -04:00
// image writer class used to output the image to a file.
class ImageOutput {
private:
Image image;
public:
explicit ImageOutput(const Image& image): image(image) {}
virtual void write(const std::string& file, const std::string& formatExtension);
};
}
#endif //STEP_2_IMAGE_H