From 4fe546f0e5e1d763c5796234d71b22ed2bd65482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Tue, 18 Oct 2022 20:34:07 +0200 Subject: [PATCH] Add support for ICC color profiles --- loadrunable.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/loadrunable.cpp b/loadrunable.cpp index cd32a0b..466e714 100644 --- a/loadrunable.cpp +++ b/loadrunable.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -14,6 +15,8 @@ #include "starfit.h" #include "wcslib/wcshdr.h" +static pcl::ICCProfile sRgbIccProfile((void*)QColorSpace(QColorSpace::SRgb).iccProfile().data()); + LoadRunable::LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level, bool thumbnail) : m_file(file), m_receiver(receiver), @@ -281,11 +284,24 @@ bool loadFITS(const QString path, ImageInfoData &info, RawImage **image) return true; } +#include "pcl/ICCProfileTransformation.h" + template bool loadPCLImage(pcl::XISFReader &xisf, RawImage **image) { PCLtype pclImage; xisf.ReadImage(pclImage); + pclImage.Status().DisableInitialization(); + + pcl::ICCProfile iccProfile = xisf.ReadICCProfile(); + if(iccProfile.IsProfile()) + { + pcl::ICCProfileTransformation iccTran; + iccTran.DisableParallelProcessing(); + iccTran.Add(iccProfile); + iccTran.Add(sRgbIccProfile); + iccTran >> pclImage; + } int numChannels = pclImage.NumberOfChannels(); cv::Mat cvImg[numChannels]; @@ -315,6 +331,7 @@ bool loadXISF(const QString &path, ImageInfoData &info, RawImage **image) { try { + pcl::XISF::EnsurePTLUTInitialized(); pcl::String pclPath = path.utf16(); pcl::XISFReader xisf; xisf.Open(pclPath); @@ -384,6 +401,9 @@ void LoadRunable::run() else { QImage img(m_file); + if(img.colorSpace().isValid()) + img.convertToColorSpace(QColorSpace::SRgb); + ExifData *exif = exif_data_new_from_file(m_file.toLocal8Bit().constData()); info.info.append({QObject::tr("Width"), QString::number(img.width())}); info.info.append({QObject::tr("Height"), QString::number(img.height())});