- for(unsigned y=0; y<data.height; ++y)
- png_read_row(priv->png, reinterpret_cast<png_byte *>(data.data+data.stride*(data.height-1-y)), 0);
+
+ if(interlace==PNG_INTERLACE_ADAM7)
+ {
+ // ADAM7 requires all rows to be loaded at once
+ unsigned n_passes = png_set_interlace_handling(priv->png);
+ rows = new png_byte *[data.height];
+ for(unsigned y=0; y<data.height; ++y)
+ rows[y] = reinterpret_cast<png_byte *>(data.data+data.stride*(data.height-1-y));
+
+ for(unsigned i=0; i<n_passes; ++i)
+ png_read_rows(priv->png, rows, 0, data.height);
+
+ delete[] rows;
+ rows = 0;
+ }
+ else
+ {
+ for(unsigned y=0; y<data.height; ++y)
+ png_read_row(priv->png, reinterpret_cast<png_byte *>(data.data+data.stride*(data.height-1-y)), 0);
+ }