From 81a3370e1d923931f060812a390016574d174731 Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Wed, 8 Jul 2020 22:53:15 -0400 Subject: [PATCH] plug-ins: fix #5357 Image marked as compressed, but DDSD_LINEARSIZE is not set. --- plug-ins/file-dds/ddsread.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/plug-ins/file-dds/ddsread.c b/plug-ins/file-dds/ddsread.c index b0aef5d416..987b1d419e 100644 --- a/plug-ins/file-dds/ddsread.c +++ b/plug-ins/file-dds/ddsread.c @@ -597,14 +597,28 @@ validate_header (dds_header_t *hdr) return FALSE; } - if ((hdr->flags & DDSD_PITCH) == (hdr->flags & DDSD_LINEARSIZE)) + if (hdr->pixelfmt.flags & DDPF_FOURCC) { - //g_message ("Warning: DDSD_PITCH or DDSD_LINEARSIZE is not set.\n"); - if (hdr->pixelfmt.flags & DDPF_FOURCC) - hdr->flags |= DDSD_LINEARSIZE; - else - hdr->flags |= DDSD_PITCH; + if (hdr->flags & DDSD_PITCH) + { + g_message ("Warning: DDSD_PITCH is incorrectly set for DDPF_FOURCC!"); + hdr->flags &= DDSD_PITCH; + } + if (! (hdr->flags & DDSD_LINEARSIZE)) + { + g_message ("Warning: DDSD_LINEARSIZE is incorrectly not set for DDPF_FOURCC!"); + hdr->flags |= DDSD_LINEARSIZE; + } } + else + { + if (! (hdr->flags & DDSD_PITCH)) + { + g_message ("Warning: DDSD_PITCH is not set!"); + hdr->flags |= DDSD_PITCH; + } + } + /* if ((hdr->pixelfmt.flags & DDPF_FOURCC) == (hdr->pixelfmt.flags & DDPF_RGB)) @@ -1148,12 +1162,6 @@ load_layer (FILE *fp, { guchar *dst; - if (!(hdr->flags & DDSD_LINEARSIZE)) - { - g_message ("Image marked as compressed, but DDSD_LINEARSIZE is not set.\n"); - return FALSE; - } - dst = g_malloc (width * height * d->gimp_bpp); memset (dst, 0, width * height * d->gimp_bpp);