Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arm64/linglong.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: '1'
package:
id: org.deepin.draw
name: deepin-draw
version: 6.5.29.1
version: 6.5.30.1
kind: app
description: |
Draw for deepin os.
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
deepin-draw (6.5.30) unstable; urgency=medium

* fix: Fixed CMYK image display issue Fixed CMYK image display issue

-- Liu Zhangjian <liuzhangjian@uniontech.com> Fri, 15 Aug 2025 11:13:48 +0800

deepin-draw (6.5.29) unstable; urgency=medium

* chore: Update version to 6.5.29
Expand Down
2 changes: 1 addition & 1 deletion linglong.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: '1'
package:
id: org.deepin.draw
name: deepin-draw
version: 6.5.29.1
version: 6.5.30.1
kind: app
description: |
Draw for deepin os.
Expand Down
2 changes: 1 addition & 1 deletion loong64/linglong.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: '1'
package:
id: org.deepin.draw
name: deepin-draw
version: 6.5.29.1
version: 6.5.30.1
kind: app
description: |
Draw for deepin os.
Expand Down
97 changes: 97 additions & 0 deletions src/service/filehander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,112 @@
#include <QFile>
#include <QDataStream>
#include <QtConcurrent>
#include <QImageReader>

Check warning on line 16 in src/service/filehander.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QImageReader> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPdfWriter>

Check warning on line 17 in src/service/filehander.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPdfWriter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QImageWriter>

Check warning on line 18 in src/service/filehander.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QImageWriter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtGlobal>

Check warning on line 19 in src/service/filehander.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtGlobal> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#if (QT_VERSION_MAJOR == 5)
#include <QDesktopWidget>
#elif (QT_VERSION_MAJOR == 6)
#include <QScreen>
#endif

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QColorSpace>
#endif

using Future = QFuture<void>;

#define CURRENTTHREADID \
reinterpret_cast<long long>(QThread::currentThreadId())

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
/**
@brief 转换图片颜色空间到sRGB,解决CMYK等颜色空间图片显示颜色不正确的问题
@param image 原始图片
@return 转换后的图片,如果不需要转换或转换失败则返回原图
@note 此功能仅在Qt6中可用
*/
static QImage convertToSRgbColorSpace(const QImage &image)
{
if (image.isNull()) {
return image;
}

QColorSpace srgbColorSpace = QColorSpace::SRgb;

bool needsConversion = false;
if (image.colorSpace().isValid()) {
qDebug() << "Image has color space:" << image.colorSpace().description();

if (image.colorSpace() != srgbColorSpace) {
needsConversion = true;
qDebug() << "Converting color space from" << image.colorSpace().description()
<< "to sRGB";
}
} else {
qDebug() << "Image has no valid color space, checking format for potential CMYK";
if (image.format() == QImage::Format_CMYK8888) {
needsConversion = true;
qDebug() << "CMYK format detected, attempting conversion";
}
}

if (!needsConversion) {
qDebug() << "No color space conversion needed";
return image;
}

QImage convertedImage = QImage();

try {
convertedImage = image.convertedToColorSpace(srgbColorSpace);
if (!convertedImage.isNull()) {
qDebug() << "Color space conversion method 1 (convertedToColorSpace) succeeded";
} else {
qDebug() << "Color space conversion method 1 failed";
}
} catch (...) {
qDebug() << "Color space conversion method 1 threw exception";
}

if (convertedImage.isNull()) {
qDebug() << "Trying color space conversion method 2: manual color space setting";

convertedImage = image.copy();
convertedImage.setColorSpace(srgbColorSpace);

if (convertedImage.format() != QImage::Format_RGB888 &&
convertedImage.format() != QImage::Format_ARGB32 &&
convertedImage.format() != QImage::Format_ARGB32_Premultiplied) {
convertedImage = convertedImage.convertToFormat(QImage::Format_RGB888);
}

if (!convertedImage.isNull()) {
qDebug() << "Color space conversion method 2 succeeded";
}
}

if (convertedImage.isNull()) {
qDebug() << "Trying color space conversion method 3: basic format conversion";
convertedImage = image.convertToFormat(QImage::Format_RGB888);
convertedImage.setColorSpace(srgbColorSpace);

if (!convertedImage.isNull()) {
qDebug() << "Color space conversion method 3 succeeded";
}
}

if (convertedImage.isNull()) {
qWarning() << "All color space conversion methods failed, returning original image";
return image;
}

return convertedImage;
}
#endif

class FileHander::FileHander_private
{
public:
Expand Down Expand Up @@ -650,7 +742,12 @@
qWarning() << "Failed to load image, file may be damaged";
d_pri()->setError(EDamagedImageFile, tr("Damaged file, unable to open it"));
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// 应用颜色空间转换,解决CMYK等格式的颜色显示问题 (仅Qt6)
img = convertToSRgbColorSpace(img);
#else
img = img.convertToFormat(QImage::Format_ARGB32);
#endif
return img;
}
return QImage();
Expand Down
Loading