From b58fc3de11f86c63347472e1640c78264ce920d9 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 13 Feb 2024 15:53:10 +0100 Subject: Preserve the ICC profile when saving TIFF files QColorSpace only handles RGB matrix-based ICC profiles. If one creates a QColorSpace out of an unsupported profile, QColorSpace will still store it internally, to avoid a data loss (e.g. loading and saving an image with an unsupported profile is meant to preserve that profile, even if Qt was not able to use it.) The TIFF plugin handler wasn't handling this case correctly, as it checked whether the color space was valid (it wasn't), rather than checking if it contained ICC data. Amend the check. Change-Id: I68b89d6b9c27c2b1e5a6e348b91ebf510f8dc10d Pick-to: 6.5 6.2 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 266f87720f9622ca75acacaa8e19987517df741e) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit a58a5d4f45eae7bda032013b3453967ff99e9bb4) --- src/plugins/imageformats/tiff/qtiffhandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index aadf134..0c6936c 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -632,8 +632,8 @@ bool QTiffHandler::write(const QImage &image) return false; } // set color space - if (image.colorSpace().isValid()) { - QByteArray iccProfile = image.colorSpace().iccProfile(); + const QByteArray iccProfile = image.colorSpace().iccProfile(); + if (!iccProfile.isEmpty()) { if (!TIFFSetField(tiff, TIFFTAG_ICCPROFILE, iccProfile.size(), reinterpret_cast(iccProfile.constData()))) { TIFFClose(tiff); return false; -- cgit v1.2.3