#pragma once #include "Color.hpp" #include "RcPtr.hpp" #include #include #include #include /// Image is a 2d array of pixels, stored as a continuous array in memory, with the first pixel /// being the top-left pixel. If a vertically flipped image data is needed, load using stb_image /// yourself, or flip the data here. class Image : public RefCounted { private: std::unique_ptr mData; glm::ivec2 mSize; int mChannels; public: Image(); bool InitFromImageFile(const char* filePath, int desiredChannels = 0); bool InitFromImageData(std::span data, int desiredChannels = 0); bool InitFromPixels(std::span pixels, glm::ivec2 dimensions, int channels); bool InitFromPixels(std::unique_ptr pixels, glm::ivec2 dimensions, int channels); /// Get the pixel at the given location. RgbaColor GetPixel(int x, int y) const; void SetPixel(int x, int y, RgbaColor color); uint8_t* GetDataPtr() const; size_t GetDataLength() const; std::span GetData() const; glm::ivec2 GetSize() const; int GetChannels() const; bool IsEmpty() const; };