The PNG Guide is an eBook based on Greg Roelofs' book, originally published by O'Reilly. |
![]() |
Home ![]() ![]() |
|
![]() ![]() ![]() ![]() ![]() ![]() |
|
readpng2_row_callback()
static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass) { mainprog_info *mainprog_ptr; if (!new_row) return; mainprog_ptr = (mainprog_info *)png_get_progressive_ptr(png_ptr); png_progressive_combine_row(png_ptr, mainprog_ptr->row_pointers[row_num], new_row); (*mainprog_ptr->mainprog_display_row)(row_num); return; } The first thing the routine does is check whether libpng provided any row data; if not, it returns immediately. Otherwise the function needs access to our mainprog_info struct, so it retrieves the pointer to that. Recall that the definition of this struct included two members that should look familiar: image_data and row_pointers. The first is the pointer to our image buffer; the second is an array of pointers giving the locations of every row within the buffer. Both were allocated and initialized when readpng2_info_callback() called its corresponding function in the main program. libpng does not require a row-pointers array in a progressive reader, but it happens to be a convenient and reasonably efficient way to access the image buffer. In any case, the row-callback function calls
|
|
Home ![]() ![]() |