- changed the handling of alpha textures. The only special case they need is with palette-less textures and this can be handled far more easily and robustly with a predefined translation instead of passing another parameter through all the layers of the texture management code. This also fixes problems with paletted PNGs that get used as an alpha texture because the old method clobbered the image's palette.

This commit is contained in:
Christoph Oelckers 2014-09-09 13:21:36 +02:00
commit acf6c259d8
12 changed files with 75 additions and 93 deletions

View file

@ -51,7 +51,7 @@
//
//===========================================================================
template<class T>
void iCopyColors(unsigned char * pout, const unsigned char * pin, bool alphatex, int count, int step)
void iCopyColors(unsigned char * pout, const unsigned char * pin, int count, int step)
{
int i;
@ -69,7 +69,7 @@ void iCopyColors(unsigned char * pout, const unsigned char * pin, bool alphatex,
}
}
typedef void (*CopyFunc)(unsigned char * pout, const unsigned char * pin, bool alphatex, int count, int step);
typedef void (*CopyFunc)(unsigned char * pout, const unsigned char * pin, int count, int step);
static CopyFunc copyfuncs[]={
iCopyColors<cRGB>,
@ -99,7 +99,7 @@ void FGLBitmap::CopyPixelDataRGB(int originx, int originy,
BYTE *buffer = GetPixels() + 4*originx + Pitch*originy;
for (int y=0;y<srcheight;y++)
{
copyfuncs[ct](&buffer[y*Pitch], &patch[y*step_y], alphatex, srcwidth, step_x);
copyfuncs[ct](&buffer[y*Pitch], &patch[y*step_y], srcwidth, step_x);
}
}
}
@ -120,18 +120,7 @@ void FGLBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int
{
BYTE *buffer = GetPixels() + 4*originx + Pitch*originy;
// alpha map with 0==transparent and 1==opaque
if (alphatex)
{
for (int i = 0; i<256; i++)
{
if (palette[i].a != 0)
penew[i] = PalEntry(255, i, 255, 255);
else
penew[i] = PalEntry(255, 0, 255, 255); // If the palette contains transparent colors keep them.
}
}
else if (translation > 0)
if (translation > 0)
{
PalEntry *ptrans = GLTranslationPalette::GetPalette(translation);
if (ptrans)