diff --git a/src/textures/buildtexture.cpp b/src/textures/buildtexture.cpp index 370bffa05..b80780317 100644 --- a/src/textures/buildtexture.cpp +++ b/src/textures/buildtexture.cpp @@ -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) diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 3bf589ec4..32f9183b3 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -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) diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index 1a9f73841..40c58d0c0 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -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; } diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index 1892d0b21..2b0aa16e6 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -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> 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