mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +00:00
- fixed what looks like a wrongly braced 'for' loop in 4 bit PCX.
The code looks wrong, unfortunately I cannot test it due to lack of an image in that format
This commit is contained in:
parent
6fcf1e0149
commit
5466e2c7c5
1 changed files with 18 additions and 13 deletions
|
@ -111,6 +111,7 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum)
|
||||||
{
|
{
|
||||||
PCXHeader hdr;
|
PCXHeader hdr;
|
||||||
|
|
||||||
|
|
||||||
file.Seek(0, FileReader::SeekSet);
|
file.Seek(0, FileReader::SeekSet);
|
||||||
if (file.Read(&hdr, sizeof(hdr)) != sizeof(hdr))
|
if (file.Read(&hdr, sizeof(hdr)) != sizeof(hdr))
|
||||||
{
|
{
|
||||||
|
@ -123,8 +124,9 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum)
|
||||||
|
|
||||||
if (hdr.manufacturer != 10 || hdr.encoding != 1) return NULL;
|
if (hdr.manufacturer != 10 || hdr.encoding != 1) return NULL;
|
||||||
if (hdr.version != 0 && hdr.version != 2 && hdr.version != 3 && hdr.version != 4 && hdr.version != 5) return NULL;
|
if (hdr.version != 0 && hdr.version != 2 && hdr.version != 3 && hdr.version != 4 && hdr.version != 5) return NULL;
|
||||||
if (hdr.bitsPerPixel != 1 && hdr.bitsPerPixel != 8) return NULL;
|
if (hdr.bitsPerPixel != 1 && hdr.bitsPerPixel != 8 && hdr.bitsPerPixel != 4) return NULL;
|
||||||
if (hdr.bitsPerPixel == 1 && hdr.numColorPlanes !=1 && hdr.numColorPlanes != 4) return NULL;
|
if (hdr.bitsPerPixel == 1 && hdr.numColorPlanes !=1 && hdr.numColorPlanes != 4) return NULL;
|
||||||
|
if (hdr.bitsPerPixel == 4 && hdr.numColorPlanes != 1) return NULL;
|
||||||
if (hdr.bitsPerPixel == 8 && hdr.bytesPerScanLine != ((hdr.xmax - hdr.xmin + 2)&~1)) return NULL;
|
if (hdr.bitsPerPixel == 8 && hdr.bytesPerScanLine != ((hdr.xmax - hdr.xmin + 2)&~1)) return NULL;
|
||||||
|
|
||||||
for (int i = 0; i < 54; i++)
|
for (int i = 0; i < 54; i++)
|
||||||
|
@ -205,7 +207,9 @@ void FPCXTexture::ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
|
|
||||||
for (i = 7; i >= 0; --i, ptr ++)
|
for (i = 7; i >= 0; --i, ptr ++)
|
||||||
{
|
{
|
||||||
*ptr = ((rle_value & (1 << i)) > 0);
|
// This can overflow for the last byte if not checked.
|
||||||
|
if (ptr < dst+Width*Height)
|
||||||
|
*ptr = ((rle_value & (1 << i)) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,13 +263,13 @@ void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr)
|
||||||
rle_count--;
|
rle_count--;
|
||||||
*(pLine++) = rle_value;
|
*(pLine++) = rle_value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* compute line's color indexes */
|
/* compute line's color indexes */
|
||||||
for (x = 0; x < Width; ++x)
|
for (x = 0; x < Width; ++x)
|
||||||
{
|
{
|
||||||
if (line[x / 8] & (128 >> (x % 8)))
|
if (line[x / 8] & (128 >> (x % 8)))
|
||||||
ptr[x] += (1 << c);
|
ptr[x] += (1 << c);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,19 +483,20 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo
|
||||||
Pixels = new uint8_t[Width*Height];
|
Pixels = new uint8_t[Width*Height];
|
||||||
if (bitcount < 8)
|
if (bitcount < 8)
|
||||||
{
|
{
|
||||||
for (int i=0;i<16;i++)
|
|
||||||
{
|
|
||||||
pe[i] = PalEntry(header.palette[i*3],header.palette[i*3+1],header.palette[i*3+2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (bitcount)
|
switch (bitcount)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 1:
|
case 1:
|
||||||
|
pe[0] = PalEntry(255, 0, 0, 0);
|
||||||
|
pe[1] = PalEntry(255, 255, 255, 255);
|
||||||
ReadPCX1bit (Pixels, lump, &header);
|
ReadPCX1bit (Pixels, lump, &header);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
for (int i = 0; i<16; i++)
|
||||||
|
{
|
||||||
|
pe[i] = PalEntry(255, header.palette[i * 3], header.palette[i * 3 + 1], header.palette[i * 3 + 2]);
|
||||||
|
}
|
||||||
ReadPCX4bits (Pixels, lump, &header);
|
ReadPCX4bits (Pixels, lump, &header);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue