- finished verification of proper texture generation and fixed a few remaining issues.

Aside from PCX 4 bit, uncompressed PCX and TGA grayscale for which I was unable to obtain test images, all others now produce proper textures in both 8 and 32 bit mode.
This commit is contained in:
Christoph Oelckers 2018-03-23 19:52:08 +01:00
parent 0a07f4c144
commit 4c781a8f65
4 changed files with 17 additions and 16 deletions

View file

@ -97,7 +97,7 @@ uint8_t *FBuildTexture::MakeTexture(FRenderStyle style)
auto c = RawPixels[i];
Pixels[i] = (style.Flags & STYLEF_RedIsAlpha) ? Remap->Palette[c].Luminance() : Remap->Remap[c];
}
return (uint8_t*)RawPixels;
return (uint8_t*)Pixels;
}
int FBuildTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)

View file

@ -475,7 +475,7 @@ void FDDSTexture::ReadRGB (FileReader &lump, uint8_t *buffer, int pixelmode)
uint32_t g = (c & GMask) << GShiftL; g |= g >> GShiftR;
uint32_t b = (c & BMask) << BShiftL; b |= b >> BShiftR;
uint32_t a = (c & AMask) << AShiftL; a |= a >> AShiftR;
*pixelp = RGBToPalette(pixelmode == PIX_Palette, r >> 24, g >> 24, b >> 24, a >> 24);
*pixelp = RGBToPalette(pixelmode == PIX_Alphatex, r >> 24, g >> 24, b >> 24, a >> 24);
}
else
{
@ -561,7 +561,7 @@ void FDDSTexture::DecompressDXT1 (FileReader &lump, uint8_t *buffer, int pixelmo
// Pick colors from the palette for each of the four colors.
if (pixelmode != PIX_ARGB) for (i = 3; i >= 0; --i)
{
palcol[i] = RGBToPalette(pixelmode == PIX_Palette, color[i]);
palcol[i] = RGBToPalette(pixelmode == PIX_Alphatex, color[i]);
}
// Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y)
@ -641,7 +641,7 @@ void FDDSTexture::DecompressDXT3 (FileReader &lump, bool premultiplied, uint8_t
// Pick colors from the palette for each of the four colors.
if (pixelmode != PIX_ARGB) for (i = 3; i >= 0; --i)
{
palcol[i] = RGBToPalette(pixelmode == PIX_Palette, color[i], false);
palcol[i] = RGBToPalette(pixelmode == PIX_Alphatex, color[i], false);
}
// Now decode this 4x4 block to the pixel buffer.
@ -717,7 +717,7 @@ void FDDSTexture::DecompressDXT5 (FileReader &lump, bool premultiplied, uint8_t
alpha[0] = block[0];
alpha[1] = block[1];
if (alpha[0] > alpha[1])
if (alpha[0] >= alpha[1])
{ // Eight-alpha block: derive the other six alphas.
for (i = 0; i < 6; ++i)
{
@ -753,7 +753,7 @@ void FDDSTexture::DecompressDXT5 (FileReader &lump, bool premultiplied, uint8_t
// Pick colors from the palette for each of the four colors.
if (pixelmode != PIX_ARGB) for (i = 3; i >= 0; --i)
{
palcol[i] = RGBToPalette(pixelmode == PIX_Palette, color[i], false);
palcol[i] = RGBToPalette(pixelmode == PIX_Alphatex, color[i], false);
}
// Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y)

View file

@ -392,19 +392,20 @@ uint8_t *FPCXTexture::MakeTexture(FRenderStyle style)
{
if (bitcount < 8)
{
for (int i = 0; i < 16; i++)
{
PaletteMap[i] = RGBToPalettePrecise(alphatex, header.palette[i * 3], header.palette[i * 3 + 1], header.palette[i * 3 + 2]);
}
switch (bitcount)
{
default:
case 1:
PaletteMap[0] = alphatex? 0 : GrayMap[0];
PaletteMap[1] = alphatex? 255 : GrayMap[255];
ReadPCX1bit (Pixels, lump, &header);
break;
case 4:
for (int i = 0; i < 16; i++)
{
PaletteMap[i] = RGBToPalettePrecise(alphatex, header.palette[i * 3], header.palette[i * 3 + 1], header.palette[i * 3 + 2]);
}
ReadPCX4bits (Pixels, lump, &header);
break;
}

View file

@ -248,7 +248,7 @@ uint8_t *FTGATexture::MakeTexture (FRenderStyle style)
r=g=b=a=0;
break;
}
PaletteMap[i] = RGBToPalettePrecise(r, g, b, a);
PaletteMap[i] = RGBToPalettePrecise(alphatex, r, g, b, a);
}
}
@ -307,7 +307,7 @@ uint8_t *FTGATexture::MakeTexture (FRenderStyle style)
for(int x=0;x<Width;x++)
{
int v = LittleShort(*p);
Pixels[x*Height + y] = RGBToPalette(((v >> 10) & 0x1f) * 8, ((v >> 5) & 0x1f) * 8, (v & 0x1f) * 8);
Pixels[x*Height + y] = RGBToPalette(alphatex, ((v >> 10) & 0x1f) * 8, ((v >> 5) & 0x1f) * 8, (v & 0x1f) * 8);
p+=step_x;
}
}
@ -319,7 +319,7 @@ uint8_t *FTGATexture::MakeTexture (FRenderStyle style)
uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height + y] = RGBToPalette(p[2], p[1], p[0]);
Pixels[x*Height + y] = RGBToPalette(alphatex, p[2], p[1], p[0]);
p+=step_x;
}
}
@ -333,7 +333,7 @@ uint8_t *FTGATexture::MakeTexture (FRenderStyle style)
uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height + y] = RGBToPalette(p[2], p[1], p[0]);
Pixels[x*Height + y] = RGBToPalette(alphatex, p[2], p[1], p[0]);
p+=step_x;
}
}
@ -345,7 +345,7 @@ uint8_t *FTGATexture::MakeTexture (FRenderStyle style)
uint8_t * p = ptr + y * Pitch;
for(int x=0;x<Width;x++)
{
Pixels[x*Height + y] = RGBToPalette(p[2], p[1], p[0], p[3]);
Pixels[x*Height + y] = RGBToPalette(alphatex, p[2], p[1], p[0], p[3]);
p+=step_x;
}
}