71 std::ostream* strmPtr =
reinterpret_cast<std::ostream*
>(
72 png_get_io_ptr(pngPtr)
76 strmPtr->write(
reinterpret_cast<const char *
>(
data), length);
92 PNG_LIBPNG_VER_STRING, NULL, NULL, NULL
134 png_infop infoPtr = handle.
pngInfoP;
137 warn(
"Frame buffer dump aborted: Unable to create"
138 "Png Write Struct\n");
143 warn(
"Frame buffer dump aborted: Unable to create"
144 "Png Info Struct\n");
152 png_set_write_fn(pngPtr, (png_voidp)&png,
writePng, NULL);
154 png_set_IHDR(pngPtr, infoPtr,
width, height, 8,
157 PNG_COMPRESSION_TYPE_DEFAULT,
158 PNG_FILTER_TYPE_DEFAULT);
160 png_write_info(pngPtr, infoPtr);
164 for (
unsigned y=0; y < height; ++y) {
165 for (
unsigned x=0;
x <
width; ++
x) {
169 png_write_row(pngPtr,
170 reinterpret_cast<png_bytep
>(rowPacked.data())
175 png_write_end(pngPtr, NULL);
unsigned height() const
Frame buffer height in pixels.
const Pixel & pixel(unsigned x, unsigned y) const
Get a pixel from an (x, y) coordinate.
unsigned width() const
Frame buffer width in pixels.
unsigned area() const
Total number of pixels in frame buffer.
static const char * _imgExtension
void write(std::ostream &png) const override
Write the frame buffer data into the provided ostream.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
static void writePng(png_structp pngPtr, png_bytep data, png_size_t length)
Write callback to use with libpng APIs.
png_structp pngWriteP
Pointer to PNG Write struct.
PngStructHandle(const PngStructHandle &)=delete
png_infop pngInfoP
Pointer to PNG Info struct.
PngStructHandle & operator=(const PngStructHandle &)=delete