diff --git a/autotests/read/pcx/ccbug_463951.pcx b/autotests/read/pcx/ccbug_463951.pcx new file mode 100644 index 0000000..193df68 Binary files /dev/null and b/autotests/read/pcx/ccbug_463951.pcx differ diff --git a/autotests/read/pcx/ccbug_463951.png b/autotests/read/pcx/ccbug_463951.png new file mode 100644 index 0000000..7067ee2 Binary files /dev/null and b/autotests/read/pcx/ccbug_463951.png differ diff --git a/src/imageformats/pcx.cpp b/src/imageformats/pcx.cpp index 477c3cc..8448556 100644 --- a/src/imageformats/pcx.cpp +++ b/src/imageformats/pcx.cpp @@ -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;