plug-ins: fix #13107 failure to read exported grayscale DDS image
When exporting a grayscale image with alpha channel as DDS while choosing "default" format, we did not set the DDPF_LUMINANCE flag, but instead used DDPF_RGB, on loading in the 3.0 branch this caused a failure to read this format due to unrecognized combination of settings. First we make sure that on exporting to also set DDPF_LUMINANCE for grayscale with alpha. Second we also make sure to zero the blue and green mask fields, since that is the expected value when these fields are not used. To support this type of older exported DDS images, we add an extra format definition for this unusual combination of DDS settings, that way we recognize them when opening and are able to load them.
This commit is contained in:
parent
4d8073a3a0
commit
3ee85e422b
2 changed files with 4 additions and 7 deletions
|
|
@ -1403,8 +1403,8 @@ write_image (FILE *fp,
|
|||
fmtbpp = 2;
|
||||
has_alpha = TRUE;
|
||||
rmask = 0x000000ff;
|
||||
gmask = 0x000000ff;
|
||||
bmask = 0x000000ff;
|
||||
gmask = 0x00000000;
|
||||
bmask = 0x00000000;
|
||||
amask = 0x0000ff00;
|
||||
}
|
||||
}
|
||||
|
|
@ -1500,17 +1500,13 @@ write_image (FILE *fp,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (bpp == 1)
|
||||
if (bpp == 1 || bpp == 2)
|
||||
{
|
||||
if (basetype == GIMP_INDEXED)
|
||||
pflags |= DDPF_PALETTEINDEXED8;
|
||||
else
|
||||
pflags |= DDPF_LUMINANCE;
|
||||
}
|
||||
else if ((bpp == 2) && (basetype == GIMP_INDEXED))
|
||||
{
|
||||
pflags |= DDPF_PALETTEINDEXED8;
|
||||
}
|
||||
else
|
||||
{
|
||||
pflags |= DDPF_RGB;
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ static struct _FMT_MAP
|
|||
{ D3DFMT_B8G8R8, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000, DDPF_RGB },
|
||||
{ D3DFMT_L8, 8, 0x000000FF, 0x000000FF, 0x000000FF, 0x00000000, DDPF_LUMINANCE },
|
||||
{ D3DFMT_A8L8, 16, 0x000000FF, 0x000000FF, 0x000000FF, 0x0000FF00, DDPF_LUMINANCE | DDPF_ALPHAPIXELS },
|
||||
{ D3DFMT_A8L8, 16, 0x000000FF, 0x000000FF, 0x000000FF, 0x0000FF00, DDPF_RGB | DDPF_ALPHAPIXELS },
|
||||
};
|
||||
#define FORMAT_MAP_COUNT (sizeof (format_map) / sizeof (format_map[0]))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue