mirror of https://github.com/GNOME/gimp.git
Issue #6886: fix loading PNG images with linear profile or gAMA chunk.
Our main issue is that GIMP does not accept indexed images with linear backend. MR !460 was an attempt to fix this, but some weird pixel data conversions were happening so the result was very wrong. We could try to investigate this and add support for linear RGB palette colors, but it's unclear how necessary it is (i.e. is there any indexed image format for which we'd want this? PNG is not one such format as will be explained below), especially that palette are u8 only right now and linear RGB u8 is not the best idea anyway. In cases reported in #6886 though, our code would say the input is linear mostly because it had a 1.0 gAMA chunk (or we could have a case with a linear profile too). But then we don't need to set such data as being in linear RGB. Just set it as non-linear RGB (R'G'B') with the associated linear profile and that's it. Setting a linear backend to an imported PNG would only be useful if PNG had some flag explicitly asking for this, bypassing any profile TRC. But as far as I can see in its spec, there is no such thing.
This commit is contained in:
parent
883eded659
commit
42a5326545
|
@ -598,7 +598,6 @@ load_image (GFile *file,
|
|||
GimpImageType layer_type; /* Type of drawable/layer */
|
||||
GimpColorProfile *profile = NULL; /* Color profile */
|
||||
gchar *profile_name = NULL; /* Profile's name */
|
||||
gboolean linear = FALSE; /* Linear RGB */
|
||||
FILE *fp; /* File pointer */
|
||||
volatile GimpImage *image = NULL; /* Image -- protected for setjmp() */
|
||||
GimpLayer *layer; /* Layer */
|
||||
|
@ -681,8 +680,7 @@ load_image (GFile *file,
|
|||
png_set_swap (pp);
|
||||
|
||||
/*
|
||||
* Get the iCCP (color profile) chunk, if any, and figure if it's
|
||||
* a linear RGB profile
|
||||
* Get the iCCP (color profile) chunk, if any.
|
||||
*/
|
||||
profile = load_color_profile (pp, info, &profile_name);
|
||||
|
||||
|
@ -790,30 +788,23 @@ load_image (GFile *file,
|
|||
}
|
||||
|
||||
if (profile)
|
||||
{
|
||||
*profile_loaded = TRUE;
|
||||
|
||||
linear = gimp_color_profile_is_linear (profile);
|
||||
}
|
||||
*profile_loaded = TRUE;
|
||||
|
||||
/*
|
||||
* Get image precision and color model
|
||||
* Get image precision and color model.
|
||||
* Note that we always import PNG as non-linear. The data might be
|
||||
* actually linear because of a linear profile, or because of a gAMA
|
||||
* chunk with 1.0 value (which we convert to a profile above). But
|
||||
* then we'll just set the right profile and that's it. Other than
|
||||
* this, PNG doesn't have (that I can see in the spec) any kind of
|
||||
* flag saying that data is linear, bypassing the profile's TRC so
|
||||
* there is basically no reason to explicitly set a linear precision.
|
||||
*/
|
||||
|
||||
if (png_get_bit_depth (pp, info) == 16)
|
||||
{
|
||||
if (linear)
|
||||
image_precision = GIMP_PRECISION_U16_LINEAR;
|
||||
else
|
||||
image_precision = GIMP_PRECISION_U16_NON_LINEAR;
|
||||
}
|
||||
image_precision = GIMP_PRECISION_U16_NON_LINEAR;
|
||||
else
|
||||
{
|
||||
if (linear)
|
||||
image_precision = GIMP_PRECISION_U8_LINEAR;
|
||||
else
|
||||
image_precision = GIMP_PRECISION_U8_NON_LINEAR;
|
||||
}
|
||||
image_precision = GIMP_PRECISION_U8_NON_LINEAR;
|
||||
|
||||
if (png_get_bit_depth (pp, info) < 8)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue