Skip to content

Commit

Permalink
Added support for interlaced pngs
Browse files Browse the repository at this point in the history
  • Loading branch information
roxlu committed Jan 28, 2015
1 parent f927058 commit 7e236cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tinylib.h
Original file line number Diff line number Diff line change
Expand Up @@ -3862,6 +3862,9 @@ extern int rx_load_png(std::string filepath,
nchannels += 1;
}

/* Handle interlacing (added 2015.01.28) */
int num_passes = png_set_interlace_handling(png_ptr);

/* When flag is set to load as RGBA, we need to the info struct */

if ((flags & RX_FLAG_LOAD_AS_RGBA) == RX_FLAG_LOAD_AS_RGBA) {
Expand Down Expand Up @@ -3947,10 +3950,15 @@ extern int rx_load_png(std::string filepath,
return -9;
}

/*
Some code on github iterate over the number of passes (see interlace
above, but this doesn't seem to be necessary.
*/
for(size_t i = 0; i < height; ++i) {
row_ptrs[i] = (png_bytep)(*pixels) +(i * stride);
}


png_read_image(png_ptr, row_ptrs);
png_read_end(png_ptr, info_ptr);

Expand Down

0 comments on commit 7e236cb

Please sign in to comment.