png_create_write_struct_2 -- register custom write function


#include <png.h>

png_structp png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn);


This interface shall register a custom write function and allocate and initialize a png_struct structure. For handling errors and warnings, as well as allocating and deallocating memory, the application can pass functions as arguments. Otherwise, the default error handling functions stderr and longjmp() will be used. The error handling routine must not return to the calling routine.

The parameter user_png_ver shall specify the version string of the library, which must be PNG_LIBPNG_VER_STRING.

The parameter error_ptr shall specify a user-defined structure for error functions.

The parameter error_fn shall specify an optional user-defined function for printing errors and aborting.

The parameter warn_fn shall specify an optional user-defined function for warnings.

The parameter mem_ptr shall specify the memory to allocate.

The parameter malloc_fn shall specify an optional user-defined memory allocation function.

The parameter free_fn shall specify an optional user-defined memory deallocation function.

Return Value

On success, returns a pointer to the png_struct that was created.

On failure, returns NULL.