mirror of
https://github.com/jorio/Pomme.git
synced 2024-06-10 06:29:31 +00:00
Fix parsing type-3 or 4 PICTs with rowbytes<250
This commit is contained in:
parent
5fc6598b47
commit
68d094c179
|
@ -240,11 +240,13 @@ static ARGBPixmap ReadPICTBits(BigEndianIStream& f, int opcode, const Rect& canv
|
|||
{
|
||||
bool directBitsOpcode = opcode == 0x009A || opcode == 0x009B;
|
||||
|
||||
//printf("@@@ ReadPictBits %04x ", opcode); LOG << "canvasRect: " << canvasRect << "\n";
|
||||
|
||||
if (directBitsOpcode) f.Skip(4); //skip junk
|
||||
int rowbytes = f.Read<SInt16>();
|
||||
//LOG << "**** rowbytes = " << rowbytes << "\n";
|
||||
|
||||
UInt16 rowbytes = f.Read<UInt16>();
|
||||
|
||||
// Get rid of MSB in rowbytes so we pass a real length to UnpackXXX functions
|
||||
bool rowbytesMSBWasHigh = 0 != (rowbytes & 0x8000);
|
||||
rowbytes &= 0x7FFF;
|
||||
|
||||
Rect frameRect = ReadRect(f);
|
||||
LOG << "frameRect " << frameRect << "\n";
|
||||
|
@ -266,7 +268,7 @@ static ARGBPixmap ReadPICTBits(BigEndianIStream& f, int opcode, const Rect& canv
|
|||
SInt16 componentSize = f.Read<SInt16>();
|
||||
SInt32 planeBytes = f.Read<SInt32>();
|
||||
SInt32 table = f.Read<SInt32>();
|
||||
if (directBitsOpcode || (rowbytes & 0x8000) != 0)
|
||||
if (directBitsOpcode || rowbytesMSBWasHigh)
|
||||
{
|
||||
f.Skip(4);
|
||||
|
||||
|
@ -281,12 +283,17 @@ static ARGBPixmap ReadPICTBits(BigEndianIStream& f, int opcode, const Rect& canv
|
|||
<< "\n\tcomponent size " << componentSize
|
||||
<< "\n\tplane bytes " << planeBytes
|
||||
<< "\n\ttable " << table
|
||||
<< "\n\trowbytes " << rowbytes << " (MSB " << (rowbytesMSBWasHigh? "hi": "lo") << ")"
|
||||
<< "\n";
|
||||
|
||||
if (pixelSize > 32) throw PICTException("pixmap invalid bpp");
|
||||
if (componentCount > 4) throw PICTException("pixmap invalid component count");
|
||||
if (componentSize <= 0) throw PICTException("pixmap invalid component size");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG << "PICT: neither directBitsOpcode nor rowbytesMSBWasHigh\n";
|
||||
}
|
||||
|
||||
auto palette = std::vector<Color>();
|
||||
if (!directBitsOpcode)
|
||||
|
@ -334,12 +341,6 @@ static ARGBPixmap ReadPICTBits(BigEndianIStream& f, int opcode, const Rect& canv
|
|||
throw PICTException("unimplemented opcode");
|
||||
}
|
||||
|
||||
if (!directBitsOpcode && (rowbytes & 0x8000) == 0)
|
||||
{
|
||||
throw PICTException("negative rowbytes");
|
||||
}
|
||||
else
|
||||
{
|
||||
int cw = Width(canvasRect);
|
||||
int ch = Height(canvasRect);
|
||||
|
||||
|
@ -358,7 +359,6 @@ static ARGBPixmap ReadPICTBits(BigEndianIStream& f, int opcode, const Rect& canv
|
|||
throw PICTException("don't know how to unpack this pixel size");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ARGBPixmap Pomme::Graphics::ReadPICT(std::istream& theF, bool skip512)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user