- int row_stride = info_ptr->width * ((pixel_depth+7)>>3);
- // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride);
-// printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth);
-
- byte *row_pointers = new byte[row_stride];
-
- /* turn on interlace handling */
- if (info_ptr->interlace_type)
- number_passes = png_set_interlace_handling(png_ptr);
- else
- number_passes = 1;
-// printf("NP = %d ", number_passes);
-
- for (int pass=0; pass< number_passes; pass++) {
- iter.upset();
- int y=0;
- do {
-// (unsigned char *)iter.GetRow();
- if (info_ptr->interlace_type) {
- if (pass>0)
- iter.GetRow(row_pointers, row_stride);
- png_read_row(png_ptr, row_pointers, NULL);
- }
- else
- png_read_row(png_ptr, row_pointers, NULL);
-
- iter.SetRow(row_pointers, row_stride);
- y++;
- } while(iter.PrevRow());
-// printf("Y=%d ",y);
- }
- delete[] row_pointers;
-
- /* read the rest of the file, getting any additional chunks
- in info_ptr */
- png_read_end(png_ptr, info_ptr);
-
- /* clean up after the read, and free any memory allocated */
- png_read_destroy(png_ptr, info_ptr, (png_info *)0);
-
- /* free the structures */
- delete(png_ptr);
- delete(info_ptr);
-
- /* close the file */
- fclose(fp);
-
- /* that's it */
- return TRUE;