27 Color( uint8_t{0U}, uint8_t{0U}, uint8_t{0U}, uint8_t{255U} )
35 Color( uint8_t iR, uint8_t iG, uint8_t iB )
37 Color( iR, iG, iB, uint8_t{255U} )
46 Color( uint8_t iR, uint8_t iG, uint8_t iB, uint8_t iA )
48 r(std::clamp(iR, uint8_t{0U}, uint8_t{255U})),
49 g(std::clamp(iG, uint8_t{0U}, uint8_t{255U})),
50 b(std::clamp(iB, uint8_t{0U}, uint8_t{255U})),
51 a(std::clamp(iA, uint8_t{0U}, uint8_t{255U}))
59 return (this->
r == rhs.
r) && (this->
g == rhs.
g) && (this->
b == rhs.
b) && (this->
a == rhs.
a);
85 ImageData(
unsigned int width,
unsigned int height);
102 ImageData(std::vector<uint8_t>
const& fileBytes);
110 ImageData(
unsigned int width,
unsigned int height, std::vector<unsigned int>
const& pixelsRGBA);
155 void SetPixel(
unsigned int x,
unsigned int y,
Color color );
163 const Color GetPixel(
unsigned int x,
unsigned int y )
const;
192 return static_cast<size_t>(mWidth) *
static_cast<size_t>(mHeight) *
sizeof(
Color);
241 unsigned int mHeight;
Represents raw 2D image data stored in memory.
void CleanAllocatedMemory()
Frees allocated memory.
void LoadImageDataRGB(std::vector< unsigned int > const &pixels)
Loads image data from a 24-bit RGB buffer.
void LoadImageDataRGBA(std::vector< unsigned int > const &pixels)
Loads image data from a 32-bit RGBA buffer.
~ImageData()
Destructor that frees memory.
void SetPixel(unsigned int x, unsigned int y, Color color)
Sets the color of a specific pixel.
void AllocateMemory(unsigned int width, unsigned int height)
Allocates memory for internal pixel storage.
unsigned int GetWidth() const
Returns the image width.
std::vector< uint8_t > GetImageDataRGB() const
Gets raw image data in RGB format.
ImageData()
Constructs an empty image.
bool LoadTextureJpegFile(char const *filename)
Loads image from a JPEG file.
static void DrawImageOnImageAtPos(unsigned int const x, unsigned int const y, ImageData &toImage, ImageData &fromImage)
Overlays one image on top of another at a given position.
void Fill(Color color)
Fills the image with a solid color.
std::vector< uint8_t > GetImageDataRGBA() const
Gets raw image data in RGBA format.
ImageData & operator=(const ImageData &rhs)
Copy assignment operator.
unsigned int GetHeight() const
Returns the image height.
void WritePngFile(char const *filename)
Writes the image data to a PNG file.
void WriteJpegFile(char const *filename)
Writes the image data to a JPEG file.
size_t GetSizeInBytes() const
Gets the total size of the image in memory.
const Color GetPixel(unsigned int x, unsigned int y) const
Retrieves the color of a specific pixel.
bool LoadTexturePngFile(char const *filename)
Loads image from a PNG file.
Represents a color with red, green, blue, and alpha channels.
Color()
Default constructor. Initializes to black with full opacity.
Color(uint8_t iR, uint8_t iG, uint8_t iB)
Constructs a fully opaque RGB color.
Color(uint8_t iR, uint8_t iG, uint8_t iB, uint8_t iA)
Constructs a color with specified RGBA channels.
bool operator==(Color const &rhs) const
Equality operator for comparing two colors.