mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 20:43:15 +00:00
- Fixed: 4, 2, and 1 bit grayscale images weren't properly supported.
- Fixed: Valgrind uninitialized memory error and a signed/unsigned warning. SVN r4288 (trunk)
This commit is contained in:
parent
17c7c32a58
commit
dabd48ab81
5 changed files with 41 additions and 5 deletions
|
@ -911,7 +911,7 @@ bool AActor::IsVisibleToPlayer() const
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (VisibleToTeam != 0 && teamplay &&
|
if (VisibleToTeam != 0 && teamplay &&
|
||||||
VisibleToTeam-1 != players[consoleplayer].userinfo.GetTeam())
|
(signed)(VisibleToTeam-1) != players[consoleplayer].userinfo.GetTeam())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const player_t* pPlayer = players[consoleplayer].camera->player;
|
const player_t* pPlayer = players[consoleplayer].camera->player;
|
||||||
|
|
|
@ -297,17 +297,33 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
|
||||||
case 0: // Grayscale
|
case 0: // Grayscale
|
||||||
if (!bAlphaTexture)
|
if (!bAlphaTexture)
|
||||||
{
|
{
|
||||||
|
BYTE *GrayMapSrc;
|
||||||
|
switch(BitDepth)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
GrayMapSrc = GrayMap;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
GrayMapSrc = GrayMap4bit;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
GrayMapSrc = GrayMap2bit;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
GrayMapSrc = GrayMap1bit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (colortype == 0 && havetRNS && trans[0] != 0)
|
if (colortype == 0 && havetRNS && trans[0] != 0)
|
||||||
{
|
{
|
||||||
bMasked = true;
|
bMasked = true;
|
||||||
PaletteSize = 256;
|
PaletteSize = 1<<BitDepth;
|
||||||
PaletteMap = new BYTE[256];
|
PaletteMap = new BYTE[PaletteSize];
|
||||||
memcpy (PaletteMap, GrayMap, 256);
|
memcpy (PaletteMap, GrayMapSrc, 256);
|
||||||
PaletteMap[trans[0]] = 0;
|
PaletteMap[trans[0]] = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PaletteMap = GrayMap;
|
PaletteMap = GrayMapSrc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -56,13 +56,29 @@ struct TexCreateInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
BYTE FTexture::GrayMap[256];
|
BYTE FTexture::GrayMap[256];
|
||||||
|
BYTE FTexture::GrayMap4bit[16];
|
||||||
|
BYTE FTexture::GrayMap2bit[4];
|
||||||
|
BYTE FTexture::GrayMap1bit[2];
|
||||||
|
|
||||||
void FTexture::InitGrayMap()
|
void FTexture::InitGrayMap()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 256; ++i)
|
for (int i = 0; i < 256; ++i)
|
||||||
{
|
{
|
||||||
GrayMap[i] = ColorMatcher.Pick (i, i, i);
|
GrayMap[i] = ColorMatcher.Pick (i, i, i);
|
||||||
|
if(i < 16)
|
||||||
|
{
|
||||||
|
const int i4 = i|(i<<4);
|
||||||
|
GrayMap4bit[i] = ColorMatcher.Pick (i4, i4, i4);
|
||||||
}
|
}
|
||||||
|
if(i < 4)
|
||||||
|
{
|
||||||
|
const int i2 = i|(i<<2)|(i<<4)|(i<<6);
|
||||||
|
GrayMap4bit[i] = ColorMatcher.Pick (i2, i2, i2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GrayMap1bit[0] = ColorMatcher.Pick (0, 0, 0);
|
||||||
|
GrayMap1bit[1] = ColorMatcher.Pick (255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
FTexture *IMGZTexture_TryCreate(FileReader &, int lumpnum);
|
FTexture *IMGZTexture_TryCreate(FileReader &, int lumpnum);
|
||||||
|
|
|
@ -283,6 +283,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
WORD Width, Height, WidthMask;
|
WORD Width, Height, WidthMask;
|
||||||
static BYTE GrayMap[256];
|
static BYTE GrayMap[256];
|
||||||
|
static BYTE GrayMap4bit[16];
|
||||||
|
static BYTE GrayMap2bit[4];
|
||||||
|
static BYTE GrayMap1bit[2];
|
||||||
FNativeTexture *Native;
|
FNativeTexture *Native;
|
||||||
|
|
||||||
FTexture (const char *name = NULL, int lumpnum = -1);
|
FTexture (const char *name = NULL, int lumpnum = -1);
|
||||||
|
|
|
@ -645,6 +645,7 @@ int FFont::SimpleTranslation (BYTE *colorsused, BYTE *translation, BYTE *reverse
|
||||||
qsort (reverse+1, j-1, 1, compare);
|
qsort (reverse+1, j-1, 1, compare);
|
||||||
|
|
||||||
*luminosity = new double[j];
|
*luminosity = new double[j];
|
||||||
|
(*luminosity)[0] = 0.0; // [BL] Prevent uninitalized memory
|
||||||
max = 0.0;
|
max = 0.0;
|
||||||
min = 100000000.0;
|
min = 100000000.0;
|
||||||
for (i = 1; i < j; i++)
|
for (i = 1; i < j; i++)
|
||||||
|
|
Loading…
Reference in a new issue