Improve CMYK writing support

Closes #11 

Requires MR !279

On formats that does not support CMYK and does not use the ScanLineConverter class during write operation, the CMYK images must be converted using the color space conversion functions of `QImage` (if ICC profile is valid).
This commit is contained in:
Mirco Miranda
2024-11-28 06:57:01 +00:00
parent b5d8b6638e
commit 374961dab4
18 changed files with 3328 additions and 7 deletions

View File

@@ -584,6 +584,9 @@ bool QJpegXLHandler::write(const QImage &image)
case QImage::Format_RGBX8888:
case QImage::Format_RGBA8888:
case QImage::Format_RGBA8888_Premultiplied:
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
case QImage::Format_CMYK8888:
#endif
save_depth = 8;
break;
case QImage::Format_Grayscale16:
@@ -757,7 +760,20 @@ bool QJpegXLHandler::write(const QImage &image)
}
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
// TODO: add native CMYK support (libjxl supports CMYK images)
QImage tmpimage;
auto cs = image.colorSpace();
if (cs.isValid() && cs.colorModel() == QColorSpace::ColorModel::Cmyk && image.format() == QImage::Format_CMYK8888) {
tmpimage = image.convertedToColorSpace(QColorSpace(QColorSpace::SRgb), tmpformat);
}
else {
tmpimage = image.convertToFormat(tmpformat);
}
#else
QImage tmpimage = image.convertToFormat(tmpformat);
#endif
const size_t xsize = tmpimage.width();
const size_t ysize = tmpimage.height();