aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLode Vandevenne <lvandeve@users.noreply.github.com>2019-11-12 22:31:25 +0100
committerGitHub <noreply@github.com>2019-11-12 22:31:25 +0100
commit2eed35e5c9dd94ff036dcba7e37ade52d46e66b5 (patch)
treefab572244b4fb60b6d484574ee7321a374dd1438
parent3fd43680473dbaa745b82ea7f302ab6855d35135 (diff)
parenta04d1e812f71a10f90ba09418cb3aa0330b52acd (diff)
downloadzopfli-2eed35e5c9dd94ff036dcba7e37ade52d46e66b5.tar.gz
Merge pull request #155 from JayXon/getPNGHeaderInfo
Use getPNGHeaderInfo() instead of decoding entire image
-rw-r--r--src/zopflipng/zopflipng_lib.cc5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/zopflipng/zopflipng_lib.cc b/src/zopflipng/zopflipng_lib.cc
index bc606ed..bff53a0 100644
--- a/src/zopflipng/zopflipng_lib.cc
+++ b/src/zopflipng/zopflipng_lib.cc
@@ -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);