[gimp] Bug 750594 - Colors in PSD files are far lighter on import and far darker on export
- From: Massimo Valentini <mvalentini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 750594 - Colors in PSD files are far lighter on import and far darker on export
- Date: Wed, 24 Jun 2015 17:04:28 +0000 (UTC)
commit 925ee2175086c5f80127729e9901ee5a6ebd7cf1
Author: ShadowKyogre <shadowkyogre public gmail com>
Date: Tue Jun 23 12:51:14 2015 -0700
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
plug-ins/file-psd/psd-load.c | 32 +++++++++++-------------
plug-ins/file-psd/psd-save.c | 54 +++++++++++++++++++++++++++++++++++-------
2 files changed, 60 insertions(+), 26 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index 108b2d2..e4477ad 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -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:
diff --git a/plug-ins/file-psd/psd-save.c b/plug-ins/file-psd/psd-save.c
index 807719b..22c4941 100644
--- a/plug-ins/file-psd/psd-save.c
+++ b/plug-ins/file-psd/psd-save.c
@@ -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;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]