68 std::ostream* strmPtr =
reinterpret_cast<std::ostream*
>(
69 png_get_io_ptr(pngPtr)
73 strmPtr->write(reinterpret_cast<const char *>(data), length);
88 PNG_LIBPNG_VER_STRING, NULL, NULL, NULL
130 png_infop infoPtr = handle.
pngInfoP;
133 warn(
"Frame buffer dump aborted: Unable to create" 134 "Png Write Struct\n");
139 warn(
"Frame buffer dump aborted: Unable to create" 140 "Png Info Struct\n");
148 png_set_write_fn(pngPtr, (png_voidp)&png,
writePng, NULL);
150 png_set_IHDR(pngPtr, infoPtr, width, height, 8,
153 PNG_COMPRESSION_TYPE_DEFAULT,
154 PNG_FILTER_TYPE_DEFAULT);
156 png_write_info(pngPtr, infoPtr);
160 for (
unsigned y=0; y < height; ++y) {
161 for (
unsigned x=0;
x <
width; ++
x) {
165 png_write_row(pngPtr,
166 reinterpret_cast<png_bytep>(rowPacked.data())
171 png_write_end(pngPtr, NULL);
PngStructHandle & operator=(const PngStructHandle &)=delete
void write(std::ostream &png) const override
Write the frame buffer data into the provided ostream.
const Pixel & pixel(unsigned x, unsigned y) const
Get a pixel from an (x, y) coordinate.
unsigned area() const
Total number of pixels in frame buffer.
png_infop pngInfoP
Pointer to PNG Info struct.
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.
static const char * _imgExtension
unsigned width() const
Frame buffer width in pixels.
unsigned height() const
Frame buffer height in pixels.