![]() |
Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
|
Represents raw 2D image data stored in memory. More...
#include <image_data.hpp>
Public Member Functions | |
| ImageData () | |
| Constructs an empty image. | |
| ImageData (unsigned int width, unsigned int height) | |
| Constructs a blank image with specified dimensions. | |
| ImageData (std::string filepath) | |
| Loads image data from a file. | |
| ImageData (std::vector< uint8_t > const &fileBytes) | |
| Constructs an image by decoding raw file bytes. | |
| ImageData (unsigned int width, unsigned int height, std::vector< unsigned int > const &pixelsRGBA) | |
| Constructs image from raw RGBA pixel buffer. | |
| ~ImageData () | |
| Destructor that frees memory. | |
| ImageData (const ImageData &src) | |
| Copy constructor. | |
| ImageData & | operator= (const ImageData &rhs) |
| Copy assignment operator. | |
| unsigned int | GetWidth () const |
| Returns the image width. | |
| unsigned int | GetHeight () const |
| Returns the image height. | |
| void | Fill (Color color) |
| Fills the image with a solid color. | |
| void | SetPixel (unsigned int x, unsigned int y, Color color) |
| Sets the color of a specific pixel. | |
| const Color | GetPixel (unsigned int x, unsigned int y) const |
| Retrieves the color of a specific pixel. | |
| std::vector< uint8_t > | GetImageDataRGBA () const |
| Gets raw image data in RGBA format. | |
| std::vector< uint8_t > | GetImageDataRGB () const |
| Gets raw image data in RGB format. | |
| size_t | GetSizeInBytes () const |
| Gets the total size of the image in memory. | |
| void | WriteJpegFile (char const *filename) |
| Writes the image data to a JPEG file. | |
| void | WritePngFile (char const *filename) |
| Writes the image data to a PNG file. | |
Static Public Member Functions | |
| 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. | |
Protected Member Functions | |
| void | AllocateMemory (unsigned int width, unsigned int height) |
| Allocates memory for internal pixel storage. | |
| void | CleanAllocatedMemory () |
| Frees allocated memory. | |
| void | LoadImageDataRGBA (std::vector< unsigned int > const &pixels) |
| Loads image data from a 32-bit RGBA buffer. | |
| void | LoadImageDataRGB (std::vector< unsigned int > const &pixels) |
| Loads image data from a 24-bit RGB buffer. | |
| bool | LoadTexturePngFile (char const *filename) |
| Loads image from a PNG file. | |
| bool | LoadTextureJpegFile (char const *filename) |
| Loads image from a JPEG file. | |
Represents raw 2D image data stored in memory.
Definition at line 72 of file image_data.hpp.
| rendering_engine::ImageData::ImageData | ( | ) |
Constructs an empty image.
Definition at line 11 of file image_data.cpp.
| rendering_engine::ImageData::ImageData | ( | unsigned int | width, |
| unsigned int | height ) |
Constructs a blank image with specified dimensions.
| width | Image width in pixels |
| height | Image height in pixels |
Definition at line 17 of file image_data.cpp.
| rendering_engine::ImageData::ImageData | ( | std::string | filepath | ) |
Loads image data from a file.
| filepath | Path to the image file (JPG or PNG) |
Definition at line 25 of file image_data.cpp.
| rendering_engine::ImageData::ImageData | ( | std::vector< uint8_t > const & | fileBytes | ) |
Constructs an image by decoding raw file bytes.
This constructor allows loading an image from a memory buffer rather than a file on disk. The data is interpreted as either PNG or JPEG depending on format detection. Decoded pixel data is stored internally in 32-bit RGBA format.
| fileBytes | Raw contents of an image file (PNG or JPEG). |
Definition at line 59 of file image_data.cpp.
| rendering_engine::ImageData::ImageData | ( | unsigned int | width, |
| unsigned int | height, | ||
| std::vector< unsigned int > const & | pixelsRGBA ) |
Constructs image from raw RGBA pixel buffer.
| width | Image width |
| height | Image height |
| pixelsRGBA | Vector of RGBA pixel data (4 bytes per pixel) |
Definition at line 100 of file image_data.cpp.
| rendering_engine::ImageData::~ImageData | ( | ) |
Destructor that frees memory.
Definition at line 108 of file image_data.cpp.
| rendering_engine::ImageData::ImageData | ( | const ImageData & | src | ) |
Copy constructor.
Definition at line 113 of file image_data.cpp.
|
protected |
Allocates memory for internal pixel storage.
| width | Image width |
| height | Image height |
Definition at line 311 of file image_data.cpp.
|
protected |
Frees allocated memory.
Definition at line 323 of file image_data.cpp.
|
static |
Overlays one image on top of another at a given position.
| x | Top-left X coordinate for the overlay |
| y | Top-left Y coordinate for the overlay |
| toImage | Destination image |
| fromImage | Source image |
Definition at line 180 of file image_data.cpp.
| void rendering_engine::ImageData::Fill | ( | Color | color | ) |
Fills the image with a solid color.
| color | The color to fill with |
Definition at line 149 of file image_data.cpp.
|
inline |
Returns the image height.
Definition at line 138 of file image_data.hpp.
| std::vector< uint8_t > rendering_engine::ImageData::GetImageDataRGB | ( | ) | const |
Gets raw image data in RGB format.
Definition at line 243 of file image_data.cpp.
| std::vector< uint8_t > rendering_engine::ImageData::GetImageDataRGBA | ( | ) | const |
Gets raw image data in RGBA format.
Definition at line 222 of file image_data.cpp.
| const Color rendering_engine::ImageData::GetPixel | ( | unsigned int | x, |
| unsigned int | y ) const |
Retrieves the color of a specific pixel.
| x | X coordinate |
| y | Y coordinate |
Definition at line 168 of file image_data.cpp.
|
inline |
Gets the total size of the image in memory.
Definition at line 190 of file image_data.hpp.
|
inline |
Returns the image width.
Definition at line 130 of file image_data.hpp.
|
protected |
Loads image data from a 24-bit RGB buffer.
Definition at line 367 of file image_data.cpp.
|
protected |
Loads image data from a 32-bit RGBA buffer.
Definition at line 341 of file image_data.cpp.
|
protected |
Loads image from a JPEG file.
Definition at line 268 of file image_data.cpp.
|
protected |
Loads image from a PNG file.
Definition at line 292 of file image_data.cpp.
Copy assignment operator.
Definition at line 129 of file image_data.cpp.
| void rendering_engine::ImageData::SetPixel | ( | unsigned int | x, |
| unsigned int | y, | ||
| Color | color ) |
Sets the color of a specific pixel.
| x | X coordinate |
| y | Y coordinate |
| color | The color to set |
Definition at line 160 of file image_data.cpp.
| void rendering_engine::ImageData::WriteJpegFile | ( | char const * | filename | ) |
Writes the image data to a JPEG file.
| filename | Path to output file |
Definition at line 263 of file image_data.cpp.
| void rendering_engine::ImageData::WritePngFile | ( | char const * | filename | ) |
Writes the image data to a PNG file.
| filename | Path to output file |
Definition at line 287 of file image_data.cpp.