The PNG Guide is an eBook based on Greg Roelofs' book, originally published by O'Reilly.


Before that happens, though, the mainprog_finish_display() routine returns control through readpng2_end_callback() to libpng and eventually back to the main program loop, which is now finished. The main program then closes the PNG file and calls readpng2_cleanup() to deallocate the PNG structs:

void readpng2_cleanup(mainprog_info *mainprog_ptr)
    png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr;
    png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr;

    if (png_ptr && info_ptr)
        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);

    mainprog_ptr->png_ptr = NULL;
    mainprog_ptr->info_ptr = NULL;

Once that is done, the program waits for user input to terminate, then it exits.

Last Update: 2010-Nov-26