[gegl] png-save: set icc profile before writing info/header
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] png-save: set icc profile before writing info/header
- Date: Wed, 11 Jul 2018 10:11:42 +0000 (UTC)
commit 1db79d81d75f82716da185a3b9d7ddcb955338e2
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Jul 11 12:10:33 2018 +0200
png-save: set icc profile before writing info/header
operations/external/png-save.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/operations/external/png-save.c b/operations/external/png-save.c
index c12b11622..f27836013 100644
--- a/operations/external/png-save.c
+++ b/operations/external/png-save.c
@@ -90,6 +90,8 @@ export_png (GeglOperation *operation,
png_color_16 white;
int png_color_type;
gchar format_string[16];
+ const Babl *babl = gegl_buffer_get_format (input);
+ const Babl *space = babl_format_get_space (babl);
const Babl *format;
src_x = result->x;
@@ -98,7 +100,6 @@ export_png (GeglOperation *operation,
height = result->height;
{
- const Babl *babl = gegl_buffer_get_format (input);
if (bit_depth != 16)
bit_depth = 8;
@@ -141,7 +142,7 @@ export_png (GeglOperation *operation,
width, height, bit_depth, png_color_type,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_DEFAULT);
- if (png_color_type == PNG_COLOR_TYPE_RGB || png_color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+ if ((space == NULL || space == babl_space ("sRGB")) && (png_color_type == PNG_COLOR_TYPE_RGB ||
png_color_type == PNG_COLOR_TYPE_RGB_ALPHA))
{
white.red = 0xff;
white.blue = 0xff;
@@ -152,27 +153,29 @@ export_png (GeglOperation *operation,
white.gray = 0xff;
png_set_bKGD (png, info, &white);
- png_write_info (png, info);
-#if BYTE_ORDER == LITTLE_ENDIAN
- if (bit_depth > 8)
- png_set_swap (png);
-#endif
-
- format = babl_format_with_space (format_string, format);
+ format = babl_format_with_space (format_string, space);
{
int icc_len;
- const Babl*space = babl_format_get_space (format);
const char *name = babl_get_name (space);
char *icc_profile;
- if (strlen (name) > 10) name = "babl/GEGL";
+ if (strlen (name) > 10) name = "GEGL";
icc_profile = babl_space_to_icc (space, name, NULL, 0, &icc_len);
- png_set_iCCP (png, info,
- name, 0, (void*)icc_profile, icc_len);
- free (icc_profile);
+ if (icc_profile)
+ {
+ png_set_iCCP (png, info,
+ name, 0, (void*)icc_profile, icc_len);
+ free (icc_profile);
+ }
}
+ png_write_info (png, info);
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+ if (bit_depth > 8)
+ png_set_swap (png);
+#endif
pixels = g_malloc0 (width * babl_format_get_bytes_per_pixel (format));
for (i=0; i< height; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]