aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-08-14 19:36:38 +0100
committerHarry Jeffery <harry@exec64.co.uk>2019-08-14 19:36:38 +0100
commitd371c7ab49d5f88a93511cb8157ef5dbd05fbf3d (patch)
treea8a74888c2bfa2fa7329d01d38cd6df320217c3b
parentff2e28f250cc2aaba39d56e817c337d2e11b520b (diff)
downloadimv-d371c7ab49d5f88a93511cb8157ef5dbd05fbf3d.tar.gz
libpng: Fix 16-bit greyscale images and add logging
-rw-r--r--src/backend_libpng.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend_libpng.c b/src/backend_libpng.c
index edf7ba3..ecbe088 100644
--- a/src/backend_libpng.c
+++ b/src/backend_libpng.c
@@ -1,6 +1,7 @@
#include "backend_libpng.h"
#include "backend.h"
#include "source.h"
+#include "log.h"
#include <assert.h>
#include <stdlib.h>
@@ -158,7 +159,15 @@ static enum backend_result open_path(const char *path, struct imv_source **src)
/* Tell libpng to give us a consistent output format */
png_set_gray_to_rgb(private->png);
png_set_filler(private->png, 0xff, PNG_FILLER_AFTER);
+ png_set_strip_16(private->png);
+ png_set_expand(private->png);
+ png_set_packing(private->png);
png_read_update_info(private->png, private->info);
+ imv_log(IMV_DEBUG, "libpng: info width=%d height=%d bit_depth=%d color_type=%d\n",
+ png_get_image_width(private->png, private->info),
+ png_get_image_height(private->png, private->info),
+ png_get_bit_depth(private->png, private->info),
+ png_get_color_type(private->png, private->info));
struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup(path);