From a04d1e812f71a10f90ba09418cb3aa0330b52acd Mon Sep 17 00:00:00 2001 From: JayXon Date: Mon, 31 Dec 2018 21:29:26 -0800 Subject: Use getPNGHeaderInfo() instead of decoding entire image Only the color type from header is needed here --- src/zopflipng/zopflipng_lib.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/zopflipng/zopflipng_lib.cc b/src/zopflipng/zopflipng_lib.cc index 811f8a4..de69995 100644 --- a/src/zopflipng/zopflipng_lib.cc +++ b/src/zopflipng/zopflipng_lib.cc @@ -229,10 +229,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 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); -- cgit v1.2.3