![]() |
Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
|
PNG read/write backend using libpng. More...
#include <cstring>#include <vector>#include <stdlib.h>#include <png.h>Go to the source code of this file.
Functions | |
| static void | SaveTextureFilePng (rendering_engine::ImageData const &imageData, char const *filename) |
| Saves image data to a PNG file. More... | |
| static bool | ReadPngFile (char const *filename, unsigned int &width, unsigned int &height, std::vector< std::uint8_t > &rgbaImageDataVector) |
| Reads a PNG file into RGBA image data. More... | |
| static bool | ReadPngFromMemory (const unsigned char *memory, size_t memorySize, unsigned int &width, unsigned int &height, std::vector< std::uint8_t > &rgbaImageDataVector) |
| Reads a PNG image from memory into RGBA image data. More... | |
PNG read/write backend using libpng.
This module bridges the Rendering Engine's ImageData abstraction and the libpng C API. It provides direct read/write routines for 8-bit RGBA images.
The implementation follows the official libpng examples and reference documentation:
The function sequence mirrors the standard libpng workflow:
png_structp and png_infop.setjmp error handling.png_set_IHDR.png_write_row / png_image_finish_read.png_destroy_write_struct.ImageData and ImageDataGpu.Definition in file image_codec_png.hpp.
|
static |
Reads a PNG file into RGBA image data.
Loads an image using libpng's simplified API and converts it to 8-bit RGBA format.
| filename | Path to the PNG file. |
| width | [out] Image width. |
| height | [out] Image height. |
| rgbaImageDataVector | [out] Filled with 4-byte-per-pixel RGBA data. |
Definition at line 135 of file image_codec_png.hpp.
|
static |
Reads a PNG image from memory into RGBA image data.
Works similarly to ReadPngFile(), but instead of loading from disk it accepts a raw memory buffer containing a complete PNG file. The data is decoded with libpng’s simplified API and converted to 8-bit RGBA format.
| memory | Pointer to the PNG file data in memory. |
| memorySize | Size of the memory buffer in bytes. |
| width | [out] Image width in pixels. |
| height | [out] Image height in pixels. |
| rgbaImageDataVector | [out] Output buffer filled with RGBA pixel data (4 bytes per pixel, stored in a vector of 32-bit unsigned integers). |
Definition at line 195 of file image_codec_png.hpp.
|
static |
Saves image data to a PNG file.
Uses libpng to write RGBA data from ImageData into a PNG file. The function performs full file initialization, metadata setup, and cleanup.
| imageData | Source image to save. |
| filename | Path to the output PNG file. |
Definition at line 47 of file image_codec_png.hpp.