mirror of https://github.com/GNOME/gimp.git
Bug 750594 - Colors in PSD files are far lighter on import and far darker on export
GIMP's PSD plugin was assuming that colors in PSD files are linearly interpolated on both export and import. This commit fixes the issue by doing the following: - when importing, assume the colors are gamma interpolated in the entire image - when importing and exporting, treat the colors in each layer as gamma interpolated - when importing and exporting, treat indexed colors as actually indexed colors - when exporting, treat the interpolation in the channels and masks as linearly interpolated
This commit is contained in:
parent
953fa220a9
commit
925ee21750
|
@ -995,16 +995,16 @@ create_gimp_image (PSDimage *img_a,
|
|||
switch (img_a->bps)
|
||||
{
|
||||
case 32:
|
||||
precision = GIMP_PRECISION_U32_LINEAR;
|
||||
precision = GIMP_PRECISION_U32_GAMMA;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
precision = GIMP_PRECISION_U16_LINEAR;
|
||||
precision = GIMP_PRECISION_U16_GAMMA;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 1:
|
||||
precision = GIMP_PRECISION_U8_LINEAR;
|
||||
precision = GIMP_PRECISION_U8_GAMMA;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2213,16 +2213,16 @@ get_layer_format (PSDimage *img_a,
|
|||
switch (img_a->bps)
|
||||
{
|
||||
case 32:
|
||||
format = babl_format ("Y u32");
|
||||
format = babl_format ("Y' u32");
|
||||
break;
|
||||
|
||||
case 16:
|
||||
format = babl_format ("Y u16");
|
||||
format = babl_format ("Y' u16");
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 1:
|
||||
format = babl_format ("Y u8");
|
||||
format = babl_format ("Y' u8");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2235,16 +2235,16 @@ get_layer_format (PSDimage *img_a,
|
|||
switch (img_a->bps)
|
||||
{
|
||||
case 32:
|
||||
format = babl_format ("YA u32");
|
||||
format = babl_format ("Y'A u32");
|
||||
break;
|
||||
|
||||
case 16:
|
||||
format = babl_format ("YA u16");
|
||||
format = babl_format ("Y'A u16");
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 1:
|
||||
format = babl_format ("YA u8");
|
||||
format = babl_format ("Y'A u8");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2254,20 +2254,19 @@ get_layer_format (PSDimage *img_a,
|
|||
break;
|
||||
|
||||
case GIMP_RGB_IMAGE:
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
switch (img_a->bps)
|
||||
{
|
||||
case 32:
|
||||
format = babl_format ("RGB u32");
|
||||
format = babl_format ("R'G'B' u32");
|
||||
break;
|
||||
|
||||
case 16:
|
||||
format = babl_format ("RGB u16");
|
||||
format = babl_format ("R'G'B' u16");
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 1:
|
||||
format = babl_format ("RGB u8");
|
||||
format = babl_format ("R'G'B' u8");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2277,20 +2276,19 @@ get_layer_format (PSDimage *img_a,
|
|||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
case GIMP_INDEXEDA_IMAGE:
|
||||
switch (img_a->bps)
|
||||
{
|
||||
case 32:
|
||||
format = babl_format ("RGBA u32");
|
||||
format = babl_format ("R'G'B'A u32");
|
||||
break;
|
||||
|
||||
case 16:
|
||||
format = babl_format ("RGBA u16");
|
||||
format = babl_format ("R'G'B'A u16");
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 1:
|
||||
format = babl_format ("RGBA u8");
|
||||
format = babl_format ("R'G'B'A u8");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -187,7 +187,8 @@ static void write_pixel_data (FILE *fd,
|
|||
static gint32 create_merged_image (gint32 imageID);
|
||||
|
||||
static const Babl* get_pixel_format (gint32 drawableID);
|
||||
|
||||
static const Babl* get_channel_format (gint32 drawableID);
|
||||
static const Babl* get_mask_format (gint32 drawableID);
|
||||
|
||||
static void
|
||||
psd_lmode_layer (gint32 idLayer,
|
||||
|
@ -1121,7 +1122,13 @@ write_pixel_data (FILE *fd,
|
|||
gint32 ltable_offset)
|
||||
{
|
||||
GeglBuffer *buffer = gimp_drawable_get_buffer (drawableID);
|
||||
const Babl *format = get_pixel_format (drawableID);
|
||||
const Babl *format;
|
||||
if (gimp_item_is_channel(drawableID)) {
|
||||
format = get_channel_format(drawableID);
|
||||
}
|
||||
else {
|
||||
format = get_pixel_format (drawableID);
|
||||
}
|
||||
gint32 tile_height = gimp_tile_height();
|
||||
gint32 height = gegl_buffer_get_height (buffer);
|
||||
gint32 width = gegl_buffer_get_width (buffer);
|
||||
|
@ -1233,6 +1240,8 @@ write_pixel_data (FILE *fd,
|
|||
if (maskID != -1)
|
||||
{
|
||||
GeglBuffer *mbuffer = gimp_drawable_get_buffer (maskID);
|
||||
const Babl *mformat = get_mask_format(maskID);
|
||||
|
||||
len = 0;
|
||||
|
||||
if (ChanLenPosition)
|
||||
|
@ -1266,7 +1275,7 @@ write_pixel_data (FILE *fd,
|
|||
GEGL_RECTANGLE (0, y,
|
||||
width,
|
||||
MIN (height - y, tile_height)),
|
||||
1.0, format, data,
|
||||
1.0, mformat, data,
|
||||
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
||||
tlen = get_compress_channel_data (&data[0],
|
||||
width,
|
||||
|
@ -1349,7 +1358,7 @@ save_data (FILE *fd,
|
|||
IFDBG printf ("\t\tWriting compressed channel data for channel %d\n",
|
||||
i);
|
||||
write_pixel_data (fd, PSDImageData.lChannels[i], NULL,
|
||||
offset + 2*imageHeight*chan);
|
||||
offset + 2*imageHeight*chan); //check how imgs are channels here
|
||||
chan++;
|
||||
}
|
||||
}
|
||||
|
@ -1543,21 +1552,24 @@ get_pixel_format (gint32 drawableID)
|
|||
switch (gimp_drawable_type (drawableID))
|
||||
{
|
||||
case GIMP_GRAY_IMAGE:
|
||||
format = babl_format ("Y u8");
|
||||
format = babl_format ("Y' u8");
|
||||
break;
|
||||
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
format = babl_format ("YA u8");
|
||||
format = babl_format ("Y'A u8");
|
||||
break;
|
||||
|
||||
case GIMP_RGB_IMAGE:
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
format = babl_format ("RGB u8");
|
||||
format = babl_format ("R'G'B' u8");
|
||||
break;
|
||||
|
||||
case GIMP_RGBA_IMAGE:
|
||||
format = babl_format ("R'G'B'A u8");
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
case GIMP_INDEXEDA_IMAGE:
|
||||
format = babl_format ("RGBA u8");
|
||||
format = gimp_drawable_get_format(drawableID);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1567,3 +1579,27 @@ get_pixel_format (gint32 drawableID)
|
|||
|
||||
return format;
|
||||
}
|
||||
|
||||
static const Babl *
|
||||
get_channel_format (gint32 drawableID)
|
||||
{
|
||||
const Babl *format;
|
||||
|
||||
/* eventually we'll put a switch statement for bit depth here to
|
||||
* support higher depth exports */
|
||||
format = babl_format ("Y u8");
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
static const Babl *
|
||||
get_mask_format (gint32 drawableID)
|
||||
{
|
||||
const Babl *format;
|
||||
|
||||
/* eventually we'll put a switch statement for bit depth here to
|
||||
* support higher depth exports */
|
||||
format = babl_format ("Y u8");
|
||||
|
||||
return format;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue