PCX: Fix reading of the extended palette

The VGA palette starts 769 bytes before the end of the file. There may be PADs between the end of the image and the start of the palette.

BUG: 463951
(cherry picked from commit 14742cb502272b8029103ce10148dfe5d0317e80)
This commit is contained in:
Mirco Miranda 2023-01-11 22:56:38 +00:00 committed by Albert Astals Cid
parent 14770318a3
commit bb66367bc8
3 changed files with 14 additions and 3 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -367,10 +367,21 @@ static void readImage8(QImage &img, QDataStream &s, const PCXHEADER &header)
}
}
quint8 flag;
// by specification, the extended palette starts at file.size() - 769
quint8 flag = 0;
if (auto device = s.device()) {
if (device->isSequential()) {
while (flag != 12 && s.status() == QDataStream::Ok) {
s >> flag;
// qDebug() << "Palette Flag: " << flag;
}
}
else {
device->seek(device->size() - 769);
s >> flag;
}
}
// qDebug() << "Palette Flag: " << flag;
if (flag == 12 && (header.Version == 5 || header.Version == 2)) {
// Read the palette
quint8 r;