EXR: Full support for gray image/colorspace

Starting with Qt 6.8, QColorSpace supports Gray and CMYK color profiles.

- On saving, grayscale images are converted to linear gray profile;
- On loading, a Grayscale image is stored in a QImage::Format_Grayscale16 instead a RGB one;
- ScanlineConverter class was updated to gray conversions.
This commit is contained in:
Mirco Miranda
2024-06-17 15:17:51 +00:00
committed by Albert Astals Cid
parent 63e21ee5f3
commit 81b7263d73
2 changed files with 45 additions and 1 deletions

View File

@ -72,9 +72,18 @@ const uchar *ScanLineConverter::convertedScanLine(const QImage &image, qint32 y)
if (!cs.isValid()) {
cs = _defaultColorSpace;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
if (tmp.depth() < 8 && cs.colorModel() == QColorSpace::ColorModel::Gray) {
tmp.convertTo(QImage::Format_Grayscale8);
}
else if (tmp.depth() < 24 && cs.colorModel() == QColorSpace::ColorModel::Rgb) {
tmp.convertTo(tmp.hasAlphaChannel() ? QImage::Format_ARGB32 : QImage::Format_RGB32);
}
#else
if (tmp.depth() < 24) {
tmp.convertTo(tmp.hasAlphaChannel() ? QImage::Format_ARGB32 : QImage::Format_RGB32);
}
#endif
tmp.setColorSpace(cs);
tmp.convertToColorSpace(_colorSpace);
}