"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plug-ins/common/file-png.c" between
gimp-2.10.10.tar.bz2 and gimp-2.10.12.tar.bz2

About: GIMP - The GNU Image Manipulation Program.

file-png.c  (gimp-2.10.10.tar.bz2):file-png.c  (gimp-2.10.12.tar.bz2)
skipping to change at line 1459 skipping to change at line 1459
gint num_passes; /* Number of interlace passes in file */ gint num_passes; /* Number of interlace passes in file */
gint pass; /* Current pass in file */ gint pass; /* Current pass in file */
gint tile_height; /* Height of tile in GIMP */ gint tile_height; /* Height of tile in GIMP */
gint width; /* image width */ gint width; /* image width */
gint height; /* image height */ gint height; /* image height */
gint begin; /* Beginning tile row */ gint begin; /* Beginning tile row */
gint end; /* Ending tile row */ gint end; /* Ending tile row */
gint num; /* Number of rows to load */ gint num; /* Number of rows to load */
FILE *fp; /* File pointer */ FILE *fp; /* File pointer */
GimpColorProfile *profile = NULL; /* Color profile */ GimpColorProfile *profile = NULL; /* Color profile */
gboolean linear; /* Save linear RGB */ gboolean out_linear; /* Save linear RGB */
GeglBuffer *buffer; /* GEGL buffer for layer */ GeglBuffer *buffer; /* GEGL buffer for layer */
const Babl *file_format; /* BABL format of file */ const Babl *file_format; /* BABL format of file */
png_structp pp; /* PNG read pointer */ png_structp pp; /* PNG read pointer */
png_infop info; /* PNG info pointer */ png_infop info; /* PNG info pointer */
gint offx, offy; /* Drawable offsets from origin */ gint offx, offy; /* Drawable offsets from origin */
guchar **pixels; /* Pixel rows */ guchar **pixels; /* Pixel rows */
guchar *fixed; /* Fixed-up pixel data */ guchar *fixed; /* Fixed-up pixel data */
guchar *pixel; /* Pixel data */ guchar *pixel; /* Pixel data */
gdouble xres, yres; /* GIMP resolution (dpi) */ gdouble xres, yres; /* GIMP resolution (dpi) */
png_color_16 background; /* Background color */ png_color_16 background; /* Background color */
png_time mod_time; /* Modification time (ie NOW) */ png_time mod_time; /* Modification time (ie NOW) */
time_t cutime; /* Time since epoch */ time_t cutime; /* Time since epoch */
struct tm *gmt; /* GMT broken down */ struct tm *gmt; /* GMT broken down */
gint color_type; /* PNG color type */ gint color_type; /* PNG color type */
gint bit_depth = 16; /* Default to bit bepth 16 */ gint bit_depth; /* Default to bit depth 16 */
guchar remap[256]; /* Re-mapping for the palette */ guchar remap[256]; /* Re-mapping for the palette */
png_textp text = NULL; png_textp text = NULL;
out_linear = FALSE;
#if defined(PNG_iCCP_SUPPORTED) #if defined(PNG_iCCP_SUPPORTED)
/* If no profile is written: export as sRGB.
* If manually assigned profile written: follow its TRC.
* If default profile written:
* - when export as auto or 16-bit: follow the storage TRC.
* - when export from 8-bit storage: follow the storage TRC.
* - when converting high bit depth to 8-bit: export as sRGB.
*/
if (pngvals.save_profile) if (pngvals.save_profile)
profile = gimp_image_get_effective_color_profile (orig_image_ID); {
profile = gimp_image_get_color_profile (orig_image_ID);
if (profile ||
pngvals.export_format == PNG_FORMAT_AUTO ||
pngvals.export_format == PNG_FORMAT_RGB16 ||
pngvals.export_format == PNG_FORMAT_RGBA16 ||
pngvals.export_format == PNG_FORMAT_GRAY16 ||
pngvals.export_format == PNG_FORMAT_GRAYA16 ||
gimp_image_get_precision (image_ID) == GIMP_PRECISION_U8_LINEAR ||
gimp_image_get_precision (image_ID) == GIMP_PRECISION_U8_GAMMA)
{
if (! profile)
profile = gimp_image_get_effective_color_profile (orig_image_ID);
out_linear = (gimp_color_profile_is_linear (profile));
}
else
{
/* When converting higher bit depth work image into 8-bit,
* with no manually assigned profile, make sure the result if
* sRGB. */
profile = gimp_image_get_effective_color_profile (orig_image_ID);
if (gimp_color_profile_is_linear (profile))
{
GimpColorProfile *saved_profile;
saved_profile = gimp_color_profile_new_srgb_trc_from_color_profile
(profile);
g_object_unref (profile);
profile = saved_profile;
}
}
}
#endif #endif
/* We save as 8-bit PNG only if:
* (1) Work image is 8-bit linear with linear profile to be saved.
* (2) Work image is 8-bit non-linear or perceptual with or without
* profile.
*/
bit_depth = 16;
switch (gimp_image_get_precision (image_ID)) switch (gimp_image_get_precision (image_ID))
{ {
case GIMP_PRECISION_U8_LINEAR: case GIMP_PRECISION_U8_LINEAR:
/* only keep 8 bit linear RGB if we also save a profile */ if (out_linear)
if (profile)
bit_depth = 8; bit_depth = 8;
case GIMP_PRECISION_U16_LINEAR:
case GIMP_PRECISION_U32_LINEAR:
case GIMP_PRECISION_HALF_LINEAR:
case GIMP_PRECISION_FLOAT_LINEAR:
case GIMP_PRECISION_DOUBLE_LINEAR:
/* save linear RGB only if we save a profile, or a loader won't
* do the right thing
*/
if (profile)
linear = TRUE;
else
linear = FALSE;
break; break;
case GIMP_PRECISION_U8_GAMMA: case GIMP_PRECISION_U8_GAMMA:
bit_depth = 8; if (! out_linear)
bit_depth = 8;
break;
case GIMP_PRECISION_U16_GAMMA: default:
case GIMP_PRECISION_U32_GAMMA:
case GIMP_PRECISION_HALF_GAMMA:
case GIMP_PRECISION_FLOAT_GAMMA:
case GIMP_PRECISION_DOUBLE_GAMMA:
linear = FALSE;
break; break;
} }
pp = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); pp = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pp) if (!pp)
{ {
/* this could happen if the compile time and run-time libpng /* this could happen if the compile time and run-time libpng
* versions do not match. * versions do not match.
*/ */
g_set_error (error, 0, 0, g_set_error (error, 0, 0,
skipping to change at line 1600 skipping to change at line 1630
/* /*
* Set color type and remember bytes per pixel count * Set color type and remember bytes per pixel count
*/ */
switch (type) switch (type)
{ {
case GIMP_RGB_IMAGE: case GIMP_RGB_IMAGE:
color_type = PNG_COLOR_TYPE_RGB; color_type = PNG_COLOR_TYPE_RGB;
if (bit_depth == 8) if (bit_depth == 8)
{ {
if (linear) if (out_linear)
file_format = babl_format ("RGB u8"); file_format = babl_format ("RGB u8");
else else
file_format = babl_format ("R'G'B' u8"); file_format = babl_format ("R'G'B' u8");
} }
else else
{ {
if (linear) if (out_linear)
file_format = babl_format ("RGB u16"); file_format = babl_format ("RGB u16");
else else
file_format = babl_format ("R'G'B' u16"); file_format = babl_format ("R'G'B' u16");
} }
break; break;
case GIMP_RGBA_IMAGE: case GIMP_RGBA_IMAGE:
color_type = PNG_COLOR_TYPE_RGB_ALPHA; color_type = PNG_COLOR_TYPE_RGB_ALPHA;
if (bit_depth == 8) if (bit_depth == 8)
{ {
if (linear) if (out_linear)
file_format = babl_format ("RGBA u8"); file_format = babl_format ("RGBA u8");
else else
file_format = babl_format ("R'G'B'A u8"); file_format = babl_format ("R'G'B'A u8");
} }
else else
{ {
if (linear) if (out_linear)
file_format = babl_format ("RGBA u16"); file_format = babl_format ("RGBA u16");
else else
file_format = babl_format ("R'G'B'A u16"); file_format = babl_format ("R'G'B'A u16");
} }
break; break;
case GIMP_GRAY_IMAGE: case GIMP_GRAY_IMAGE:
color_type = PNG_COLOR_TYPE_GRAY; color_type = PNG_COLOR_TYPE_GRAY;
if (bit_depth == 8) if (bit_depth == 8)
{ {
if (linear) if (out_linear)
file_format = babl_format ("Y u8"); file_format = babl_format ("Y u8");
else else
file_format = babl_format ("Y' u8"); file_format = babl_format ("Y' u8");
} }
else else
{ {
if (linear) if (out_linear)
file_format = babl_format ("Y u16"); file_format = babl_format ("Y u16");
else else
file_format = babl_format ("Y' u16"); file_format = babl_format ("Y' u16");
} }
break; break;
case GIMP_GRAYA_IMAGE: case GIMP_GRAYA_IMAGE:
color_type = PNG_COLOR_TYPE_GRAY_ALPHA; color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
if (bit_depth == 8) if (bit_depth == 8)
{ {
if (linear) if (out_linear)
file_format = babl_format ("YA u8"); file_format = babl_format ("YA u8");
else else
file_format = babl_format ("Y'A u8"); file_format = babl_format ("Y'A u8");
} }
else else
{ {
if (linear) if (out_linear)
file_format = babl_format ("YA u16"); file_format = babl_format ("YA u16");
else else
file_format = babl_format ("Y'A u16"); file_format = babl_format ("Y'A u16");
} }
break; break;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
color_type = PNG_COLOR_TYPE_PALETTE; color_type = PNG_COLOR_TYPE_PALETTE;
file_format = gimp_drawable_get_format (drawable_ID); file_format = gimp_drawable_get_format (drawable_ID);
pngg.has_plte = TRUE; pngg.has_plte = TRUE;
skipping to change at line 1695 skipping to change at line 1725
g_set_error (error, 0, 0, "Image type can't be exported as PNG"); g_set_error (error, 0, 0, "Image type can't be exported as PNG");
return FALSE; return FALSE;
} }
} }
else else
{ {
switch (pngvals.export_format) switch (pngvals.export_format)
{ {
case PNG_FORMAT_RGB8: case PNG_FORMAT_RGB8:
color_type = PNG_COLOR_TYPE_RGB; color_type = PNG_COLOR_TYPE_RGB;
file_format = babl_format ("R'G'B' u8"); if (out_linear)
file_format = babl_format ("RGB u8");
else
file_format = babl_format ("R'G'B' u8");
bit_depth = 8; bit_depth = 8;
break; break;
case PNG_FORMAT_GRAY8: case PNG_FORMAT_GRAY8:
color_type = PNG_COLOR_TYPE_GRAY; color_type = PNG_COLOR_TYPE_GRAY;
file_format = babl_format ("Y' u8"); if (out_linear)
file_format = babl_format ("Y u8");
else
file_format = babl_format ("Y' u8");
bit_depth = 8; bit_depth = 8;
break; break;
case PNG_FORMAT_AUTO: // shut up gcc
case PNG_FORMAT_RGBA8: case PNG_FORMAT_RGBA8:
color_type = PNG_COLOR_TYPE_RGB_ALPHA; color_type = PNG_COLOR_TYPE_RGB_ALPHA;
file_format = babl_format ("R'G'B'A u8"); if (out_linear)
file_format = babl_format ("RGBA u8");
else
file_format = babl_format ("R'G'B'A u8");
bit_depth = 8; bit_depth = 8;
break; break;
case PNG_FORMAT_GRAYA8: case PNG_FORMAT_GRAYA8:
color_type = PNG_COLOR_TYPE_GRAY_ALPHA; color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
file_format = babl_format ("Y'A u8"); if (out_linear)
file_format = babl_format ("YA u8");
else
file_format = babl_format ("Y'A u8");
bit_depth = 8; bit_depth = 8;
break; break;
case PNG_FORMAT_RGB16: case PNG_FORMAT_RGB16:
color_type = PNG_COLOR_TYPE_RGB; color_type = PNG_COLOR_TYPE_RGB;
file_format = babl_format ("R'G'B' u16"); if (out_linear)
file_format = babl_format ("RGB u16");
else
file_format = babl_format ("R'G'B' u16");
bit_depth = 16; bit_depth = 16;
break; break;
case PNG_FORMAT_GRAY16: case PNG_FORMAT_GRAY16:
color_type = PNG_COLOR_TYPE_GRAY; color_type = PNG_COLOR_TYPE_GRAY;
file_format = babl_format ("Y' u16"); if (out_linear)
file_format = babl_format ("Y u16");
else
file_format = babl_format ("Y' u16");
bit_depth = 16; bit_depth = 16;
break; break;
case PNG_FORMAT_RGBA16: case PNG_FORMAT_RGBA16:
color_type = PNG_COLOR_TYPE_RGB_ALPHA; color_type = PNG_COLOR_TYPE_RGB_ALPHA;
file_format = babl_format ("R'G'B'A u16"); if (out_linear)
file_format = babl_format ("RGBA u16");
else
file_format = babl_format ("R'G'B'A u16");
bit_depth = 16; bit_depth = 16;
break; break;
case PNG_FORMAT_GRAYA16: case PNG_FORMAT_GRAYA16:
color_type = PNG_COLOR_TYPE_GRAY_ALPHA; color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
file_format = babl_format ("Y'A u16"); if (out_linear)
file_format = babl_format ("YA u16");
else
file_format = babl_format ("Y'A u16");
bit_depth = 16; bit_depth = 16;
break; break;
case PNG_FORMAT_AUTO:
g_return_val_if_reached (FALSE);
} }
} }
bpp = babl_format_get_bytes_per_pixel (file_format); bpp = babl_format_get_bytes_per_pixel (file_format);
/* Note: png_set_IHDR() must be called before any other png_set_*() /* Note: png_set_IHDR() must be called before any other png_set_*()
functions. */ functions. */
png_set_IHDR (pp, info, width, height, bit_depth, color_type, png_set_IHDR (pp, info, width, height, bit_depth, color_type,
pngvals.interlaced ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE, pngvals.interlaced ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_COMPRESSION_TYPE_BASE,
skipping to change at line 1819 skipping to change at line 1874
mod_time.year = gmt->tm_year + 1900; mod_time.year = gmt->tm_year + 1900;
mod_time.month = gmt->tm_mon + 1; mod_time.month = gmt->tm_mon + 1;
mod_time.day = gmt->tm_mday; mod_time.day = gmt->tm_mday;
mod_time.hour = gmt->tm_hour; mod_time.hour = gmt->tm_hour;
mod_time.minute = gmt->tm_min; mod_time.minute = gmt->tm_min;
mod_time.second = gmt->tm_sec; mod_time.second = gmt->tm_sec;
png_set_tIME (pp, info, &mod_time); png_set_tIME (pp, info, &mod_time);
} }
#if defined(PNG_iCCP_SUPPORTED) #if defined(PNG_iCCP_SUPPORTED)
if (profile) if (pngvals.save_profile)
{ {
GimpParasite *parasite; GimpParasite *parasite;
gchar *profile_name = NULL; gchar *profile_name = NULL;
const guint8 *icc_data; const guint8 *icc_data;
gsize icc_length; gsize icc_length;
icc_data = gimp_color_profile_get_icc_profile (profile, &icc_length); icc_data = gimp_color_profile_get_icc_profile (profile, &icc_length);
parasite = gimp_image_get_parasite (orig_image_ID, parasite = gimp_image_get_parasite (orig_image_ID,
"icc-profile-name"); "icc-profile-name");
skipping to change at line 1843 skipping to change at line 1898
"UTF-8", "ISO-8859-1", NULL, NULL, NULL); "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
png_set_iCCP (pp, png_set_iCCP (pp,
info, info,
profile_name ? profile_name : "ICC profile", profile_name ? profile_name : "ICC profile",
0, 0,
icc_data, icc_data,
icc_length); icc_length);
g_free (profile_name); g_free (profile_name);
g_object_unref (profile); g_object_unref (profile);
} }
#endif #endif
#ifdef PNG_zTXt_SUPPORTED #ifdef PNG_zTXt_SUPPORTED
/* Small texts are not worth compressing and will be even bigger if compressed. /* Small texts are not worth compressing and will be even bigger if compressed.
Empirical length limit of a text being worth compressing. */ Empirical length limit of a text being worth compressing. */
#define COMPRESSION_WORTHY_LENGTH 200 #define COMPRESSION_WORTHY_LENGTH 200
#endif #endif
 End of changes. 30 change blocks. 
44 lines changed or deleted 99 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)