- fixes in DDS decoder.

- let FPatchTexture use the inline color getters.
This commit is contained in:
Christoph Oelckers 2018-03-22 00:54:03 +01:00
parent b473838627
commit 1756035594
2 changed files with 14 additions and 13 deletions

View file

@ -474,7 +474,8 @@ void FDDSTexture::ReadRGB (FileReader &lump, uint8_t *buffer, int pixelmode)
uint32_t r = (c & RMask) << RShiftL; r |= r >> RShiftR; uint32_t r = (c & RMask) << RShiftL; r |= r >> RShiftR;
uint32_t g = (c & GMask) << GShiftL; g |= g >> GShiftR; uint32_t g = (c & GMask) << GShiftL; g |= g >> GShiftR;
uint32_t b = (c & BMask) << BShiftL; b |= b >> BShiftR; uint32_t b = (c & BMask) << BShiftL; b |= b >> BShiftR;
*pixelp = RGBToPalette(pixelmode == PIX_Palette, r >> 24, g >> 24, b >> 24); uint32_t a = (c & AMask) << AShiftL; a |= a >> AShiftR;
*pixelp = RGBToPalette(pixelmode == PIX_Palette, r >> 24, g >> 24, b >> 24, a >> 24);
} }
else else
{ {
@ -658,11 +659,17 @@ void FDDSTexture::DecompressDXT3 (FileReader &lump, bool premultiplied, uint8_t
{ {
break; break;
} }
if (pixelmode != PIX_ARGB) if (pixelmode == PIX_Palette)
{ {
buffer[oy + y + (ox + x) * Height] = ((yalphaslice >> (x*4)) & 15) < 8 ? buffer[oy + y + (ox + x) * Height] = ((yalphaslice >> (x*4)) & 15) < 8 ?
(bMasked = true, 0) : palcol[(yslice >> (x + x)) & 3]; (bMasked = true, 0) : palcol[(yslice >> (x + x)) & 3];
} }
else if (pixelmode == PIX_Alphatex)
{
int alphaval = ((yalphaslice >> (x * 4)) & 15);
int palval = palcol[(yslice >> (x + x)) & 3];
buffer[oy + y + (ox + x) * Height] = palval * alphaval / 15;
}
else else
{ {
uint8_t * tcp = &buffer[(ox + x)*4 + (oy + y) * Width*4]; uint8_t * tcp = &buffer[(ox + x)*4 + (oy + y) * Width*4];
@ -670,7 +677,7 @@ void FDDSTexture::DecompressDXT3 (FileReader &lump, bool premultiplied, uint8_t
tcp[0] = color[c].r; tcp[0] = color[c].r;
tcp[1] = color[c].g; tcp[1] = color[c].g;
tcp[2] = color[c].b; tcp[2] = color[c].b;
tcp[3] = color[c].a; tcp[3] = ((yalphaslice >> (x * 4)) & 15) * 0x11;
} }
} }
} }

View file

@ -119,7 +119,7 @@ static bool CheckIfPatch(FileReader & file, bool &isalpha)
{ {
// only check this if the texture passed validation. // only check this if the texture passed validation.
// Here is a good point because we already have a valid buffer of the lump's data. // Here is a good point because we already have a valid buffer of the lump's data.
isalpha = checkPatchForAlpha(data, file.GetLength()); isalpha = checkPatchForAlpha(data, (uint32_t)file.GetLength());
} }
return !gapAtStart; return !gapAtStart;
} }
@ -183,20 +183,14 @@ uint8_t *FPatchTexture::MakeTexture (FRenderStyle style)
maxcol = (const column_t *)((const uint8_t *)patch + Wads.LumpLength (SourceLump) - 3); maxcol = (const column_t *)((const uint8_t *)patch + Wads.LumpLength (SourceLump) - 3);
if (style.Flags & STYLEF_RedIsAlpha) remap = GetRemap(style, isalpha);
{ // Special case for skies
remap = translationtables[TRANSLATION_Standard][isalpha? STD_Gray : STD_Grayscale]->Remap; if (bNoRemap0 && remap == GPalette.Remap)
}
else if (bNoRemap0)
{ {
memcpy(remaptable, GPalette.Remap, 256); memcpy(remaptable, GPalette.Remap, 256);
remaptable[0] = 0; remaptable[0] = 0;
remap = remaptable; remap = remaptable;
} }
else
{
remap = isalpha? GrayMap : GPalette.Remap;
}
if (badflag) if (badflag)
{ {