[gimp] plug-ins: fix #7566 Import Issues with Indexed .dds Images
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: fix #7566 Import Issues with Indexed .dds Images
- Date: Wed, 1 Dec 2021 20:16:39 +0000 (UTC)
commit dec5ca22199103ec3c2f378894b97db637e8c62c
Author: Jacob Boerema <jgboerema gmail com>
Date: Wed Dec 1 15:01:26 2021 -0500
plug-ins: fix #7566 Import Issues with Indexed .dds Images
This proved to be both an import and export issue.
Our import set expected format as RGB, causing garbled image output.
Our export for indexed images converted to grayscale first, although the
palette was correctly saved. This caused wrong palette indexes on import.
For indexed images, on import, we request the actual indexed format after
creating the layer with gimp_drawable_get_format, which gives us a correct
indexed Babl format.
Also added logic for indexed with alpha, although I have no sample images
to test this.
For indexed images on export we do the same: use gimp_drawable_get_format
to get an actual indexed Babl format.
plug-ins/file-dds/ddsread.c | 11 +++++++++--
plug-ins/file-dds/ddswrite.c | 4 +++-
2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/file-dds/ddsread.c b/plug-ins/file-dds/ddsread.c
index 72102d0e1c..1820856704 100644
--- a/plug-ins/file-dds/ddsread.c
+++ b/plug-ins/file-dds/ddsread.c
@@ -995,7 +995,6 @@ load_layer (FILE *fp,
if (hdr->pixelfmt.flags & DDPF_PALETTEINDEXED8)
{
type = GIMP_INDEXED_IMAGE;
- bablfmt = babl_format ("R'G'B' u8");
}
else if (hdr->pixelfmt.rmask == 0xe0)
{
@@ -1014,7 +1013,12 @@ load_layer (FILE *fp,
}
break;
case 2:
- if (hdr->pixelfmt.amask == 0xf000) /* RGBA4 */
+ if ((hdr->pixelfmt.flags & (DDPF_PALETTEINDEXED8 + DDPF_ALPHA)) ==
+ DDPF_PALETTEINDEXED8 + DDPF_ALPHA)
+ {
+ type = GIMP_INDEXEDA_IMAGE;
+ }
+ else if (hdr->pixelfmt.amask == 0xf000) /* RGBA4 */
{
type = GIMP_RGBA_IMAGE;
bablfmt = babl_format ("R'G'B'A u8");
@@ -1048,6 +1052,9 @@ load_layer (FILE *fp,
gimp_image_insert_layer (image, layer, NULL, *l);
+ if (type == GIMP_INDEXED_IMAGE || type == GIMP_INDEXEDA_IMAGE)
+ bablfmt = gimp_drawable_get_format (GIMP_DRAWABLE (layer));
+
if ((*l)++) gimp_item_set_visible (GIMP_ITEM (layer), FALSE);
buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
diff --git a/plug-ins/file-dds/ddswrite.c b/plug-ins/file-dds/ddswrite.c
index 04df36aac6..4ada0d3966 100644
--- a/plug-ins/file-dds/ddswrite.c
+++ b/plug-ins/file-dds/ddswrite.c
@@ -876,7 +876,9 @@ write_layer (FILE *fp,
src = g_malloc (w * h * bpp);
- if (bpp == 1)
+ if (basetype == GIMP_INDEXED)
+ format = gimp_drawable_get_format (drawable);
+ else if (bpp == 1)
format = babl_format ("Y' u8");
else if (bpp == 2)
format = babl_format ("Y'A u8");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]