From 500eb1a9b1bc02f690025bdbcc6bde1920146ed5 Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Mon, 23 Oct 2017 14:15:48 +0200 Subject: [PATCH] loaders: PNG: Wire up gamma tables. Now the loader at least tries to set the gamma value for the pixmap, which is later used by some of the resampling functions, etc. Signed-off-by: Cyril Hrubis --- libs/loaders/GP_PNG.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index fa01db1c..d0191cf5 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -196,6 +196,9 @@ static int read_convert_bitmap(GP_Pixmap *res, GP_ProgressCallback *callback, unsigned int y; + if (gamma < 0.01) + GP_PixmapSetGamma(res, 2.2); + for (y = 0; y < res->h; y++) { png_read_row(png, (void*)row, NULL); uint8_t *rrow = GP_PIXEL_ADDR(res, 0, y); @@ -385,6 +388,9 @@ int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, goto err2; } + if (gamma > 0.1) + GP_PixmapSetGamma(res, 1/gamma); + if (color_type == PNG_COLOR_TYPE_GRAY && depth < 8) png_set_packswap(png); -- 2.11.4.GIT