diff --git a/autotests/read/ras/pal1bit.png b/autotests/read/ras/pal1bit.png new file mode 100644 index 0000000..42febbc Binary files /dev/null and b/autotests/read/ras/pal1bit.png differ diff --git a/autotests/read/ras/pal1bit.ras b/autotests/read/ras/pal1bit.ras new file mode 100644 index 0000000..36f6178 Binary files /dev/null and b/autotests/read/ras/pal1bit.ras differ diff --git a/src/imageformats/ras.cpp b/src/imageformats/ras.cpp index 5434744..8ad3076 100644 --- a/src/imageformats/ras.cpp +++ b/src/imageformats/ras.cpp @@ -275,8 +275,17 @@ static bool LoadRAS(QDataStream &s, const RasHeader &ras, QImage &img) continue; } - // Image with palette - if (ras.ColorMapType == RAS_COLOR_MAP_TYPE_RGB && (ras.Depth == 1 || ras.Depth == 8)) { + // Image with palette 1-bit (one bit per index, unpacked to an index per byte) + if (ras.ColorMapType == RAS_COLOR_MAP_TYPE_RGB && ras.Depth == 1) { + auto scanLine = img.scanLine(y); + for (quint32 x = 0; x < ras.Width; x++) { + scanLine[x] = (quint8(rasLine.at(x / 8)) >> (7 - (x % 8))) & 1; + } + continue; + } + + // Image with palette 8-bit + if (ras.ColorMapType == RAS_COLOR_MAP_TYPE_RGB && ras.Depth == 8) { std::memcpy(img.scanLine(y), rasLine.constData(), bytesPerLine); continue; }