[Bf-blender-cvs] [e919a37] master: Fix T40818: libpng warning: iCCP: known incorrect sRGB profile

Sergey Sharybin noreply at git.blender.org
Mon Jun 30 17:08:58 CEST 2014


Commit: e919a37e97874d2e7b5abc134eab7ed43c993b18
Author: Sergey Sharybin
Date:   Mon Jun 30 21:06:23 2014 +0600
https://developer.blender.org/rBe919a37e97874d2e7b5abc134eab7ed43c993b18

Fix T40818: libpng warning: iCCP: known incorrect sRGB profile

Suppress warning for now, it's harmless and only happens
with new libpng.

In the future we might try enabling it for non-datatoc-ed
files, but it's really not worth spending lots of time on.

===================================================================

M	source/blender/imbuf/intern/png.c

===================================================================

diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index b620dbd..23f5cc1 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -35,8 +35,10 @@
 
 #include "BLI_utildefines.h"
 #include "BLI_fileops.h"
-
 #include "BLI_math.h"
+
+#include "BKE_global.h"
+
 #include "MEM_guardedalloc.h"
 
 #include "imbuf.h"
@@ -484,6 +486,23 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
 	return(1);
 }
 
+static void imb_png_warning(png_structp png_ptr, png_const_charp message)
+{
+	/* We supress iCCP warnings. That's how Blender always used to behave,
+	 * and with new libpng it became too much picky, giving a warning on
+	 * the splash screen even.
+	 */
+	if ((G.debug & G_DEBUG) == 0 && !strncmp(message, "iCCP", 4)) {
+		return;
+	}
+	fprintf(stderr, "libpng warning: %s\n", message);
+}
+
+static void imb_png_error(png_structp png_ptr, png_const_charp message)
+{
+	fprintf(stderr, "libpng error: %s\n", message);
+}
+
 ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
 {
 	struct ImBuf *ibuf = NULL;
@@ -513,6 +532,8 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[I
 		return NULL;
 	}
 
+	png_set_error_fn(png_ptr, NULL, imb_png_error, imb_png_warning);
+
 	info_ptr = png_create_info_struct(png_ptr);
 	if (info_ptr == NULL) {
 		png_destroy_read_struct(&png_ptr, (png_infopp)NULL,




More information about the Bf-blender-cvs mailing list