Skip to content

Commit

Permalink
Merge pull request #155 from JayXon/getPNGHeaderInfo
Browse files Browse the repository at this point in the history
Use getPNGHeaderInfo() instead of decoding entire image
  • Loading branch information
lvandeve authored Nov 12, 2019
2 parents 3fd4368 + a04d1e8 commit 2eed35e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/zopflipng/zopflipng_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ unsigned TryOptimize(
// For very small output, also try without palette, it may be smaller thanks
// to no palette storage overhead.
if (!error && out->size() < 4096 && !keep_colortype) {
lodepng::State teststate;
std::vector<unsigned char> temp;
lodepng::decode(temp, w, h, teststate, *out);
if (teststate.info_png.color.colortype == LCT_PALETTE) {
if (lodepng::getPNGHeaderInfo(*out).color.colortype == LCT_PALETTE) {
LodePNGColorStats stats;
lodepng_color_stats_init(&stats);
lodepng_compute_color_stats(&stats, &image[0], w, h, &state.info_raw);
Expand Down

0 comments on commit 2eed35e

Please sign in to comment.