mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
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
This commit is contained in:
parent
4c6d2b92b6
commit
14742cb502
BIN
autotests/read/pcx/ccbug_463951.pcx
Normal file
BIN
autotests/read/pcx/ccbug_463951.pcx
Normal file
Binary file not shown.
BIN
autotests/read/pcx/ccbug_463951.png
Normal file
BIN
autotests/read/pcx/ccbug_463951.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
@ -367,10 +367,21 @@ static void readImage8(QImage &img, QDataStream &s, const PCXHEADER &header)
|
||||
}
|
||||
}
|
||||
|
||||
quint8 flag;
|
||||
s >> flag;
|
||||
// qDebug() << "Palette Flag: " << 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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user