I'm trying to use libpng to save screenshots from an 8-bit color framebuffer into an 8-bit indexed color PNG file, but libpng crashes ntdll.dll. What's happening?
#include <windows.h>
#include <png.h>
void WriteScreenshot (unsigned char *filename, unsigned char *buffer, unsigned char *palette, unsigned int width, unsigned int height)
{
png_image image;
memset (&image, 0, sizeof image);
image.version = PNG_IMAGE_VERSION;
image.format = PNG_FORMAT_RGB_COLORMAP;
image.colormap_entries = 256;
image.width = width;
image.height = height;
png_image_write_to_file (&image, filename, false, buffer, width, palette);
}
Debugger information:
Debugger name and version: GNU gdb (GDB) 8.3.1
Child process PID: 8948
In ntdll!RtlUserThreadStart () (C:\Windows\SYSTEM32\ntdll.dll)
Stack information:
Stack level 0, frame at 0x0:
eip = 0x77214f90 in ntdll!RtlUserThreadStart; saved eip = <not saved>
Outermost frame: outermost
Arglist at unknown address.
Locals at unknown address, Previous frame's sp in esp