Commit 79f1c25e authored by Daniel Novomeský's avatar Daniel Novomeský Committed by Daniel Novomeský
Browse files

Read color profile from QImage

Increase minimal Qt version
parent c23ac6c8
......@@ -10,7 +10,7 @@ project(gwenview VERSION ${RELEASE_SERVICE_VERSION})
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake )
set (QT_MIN_VERSION "5.12.0")
set (QT_MIN_VERSION "5.14.0")
set (KF5_MIN_VERSION "5.68.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
......
......@@ -187,6 +187,22 @@ Profile::Ptr Profile::loadFromExiv2Image(const Exiv2::Image* image)
return ptr;
}
Profile::Ptr Profile::loadFromICC(const QByteArray &data)
{
Profile::Ptr ptr;
int size = data.size();
if (size > 0) {
cmsHPROFILE hProfile = cmsOpenProfileFromMem(data, size);
if (hProfile) {
ptr = new Profile(hProfile);
}
}
return ptr;
}
cmsHPROFILE Profile::handle() const
{
return d->mProfile;
......
......@@ -66,6 +66,7 @@ public:
static Profile::Ptr loadFromImageData(const QByteArray& data, const QByteArray& format);
static Profile::Ptr loadFromExiv2Image(const Exiv2::Image* image);
static Profile::Ptr loadFromICC(const QByteArray &data);
static Profile::Ptr getMonitorProfile();
static Profile::Ptr getSRgbProfile();
......
......@@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Qt
#include <QBuffer>
#include <QByteArray>
#include <QColorSpace>
#include <QFile>
#include <QFuture>
#include <QFutureWatcher>
......@@ -201,6 +202,8 @@ struct LoadingDocumentImplPrivate
mExiv2Image = loader.popImage();
}
QImageReader reader;
#ifdef KDCRAW_FOUND
if (KDcrawIface::KDcraw::rawFilesList().contains(QString::fromLatin1(mFormatHint))) {
QByteArray previewData;
......@@ -233,7 +236,8 @@ struct LoadingDocumentImplPrivate
#else
{
#endif
QImageReader reader(&buffer, mFormatHint);
reader.setFormat(mFormatHint);
reader.setDevice(&buffer);
mImageSize = reader.size();
if (!reader.canRead()) {
......@@ -288,6 +292,13 @@ struct LoadingDocumentImplPrivate
mCmsProfile = Cms::Profile::loadFromImageData(mData, mFormat);
}
if (!mCmsProfile && reader.canRead()) {
const QImage qtimage = reader.read();
if (!qtimage.isNull()) {
mCmsProfile = Cms::Profile::loadFromICC(qtimage.colorSpace().iccProfile());
}
}
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment