aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJayXon <jayxon@gmail.com>2018-12-31 21:29:26 -0800
committerJayXon <jayxon@gmail.com>2019-11-03 01:59:04 -0700
commita04d1e812f71a10f90ba09418cb3aa0330b52acd (patch)
tree3eac41bd03511df1ac18a2708f5ac151cb9f1afc
parent129fdf786cb8340ea53f83b14c737047481afeb5 (diff)
downloadzopfli-a04d1e812f71a10f90ba09418cb3aa0330b52acd.tar.gz
Use getPNGHeaderInfo() instead of decoding entire image
Only the color type from header is needed here
-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 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<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);