plug-ins: fix #5357 Image marked as compressed, but DDSD_LINEARSIZE is not set.

This commit is contained in:
Jacob Boerema 2020-07-08 22:53:15 -04:00 committed by Jehan
parent a3a88bf6b9
commit 81a3370e1d
1 changed files with 20 additions and 12 deletions

View File

@ -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);