70 std::ostream* strmPtr =
reinterpret_cast<std::ostream*
>(
71 png_get_io_ptr(pngPtr)
75 strmPtr->write(reinterpret_cast<const char *>(data), length);
90 PNG_LIBPNG_VER_STRING, NULL, NULL, NULL
132 png_infop infoPtr = handle.
pngInfoP;
135 warn(
"Frame buffer dump aborted: Unable to create" 136 "Png Write Struct\n");
141 warn(
"Frame buffer dump aborted: Unable to create" 142 "Png Info Struct\n");
150 png_set_write_fn(pngPtr, (png_voidp)&png,
writePng, NULL);
152 png_set_IHDR(pngPtr, infoPtr, width, height, 8,
155 PNG_COMPRESSION_TYPE_DEFAULT,
156 PNG_FILTER_TYPE_DEFAULT);
158 png_write_info(pngPtr, infoPtr);
162 for (
unsigned y=0; y < height; ++y) {
163 for (
unsigned x=0;
x <
width; ++
x) {
167 png_write_row(pngPtr,
168 reinterpret_cast<png_bytep>(rowPacked.data())
173 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.