Add support for ICC color profiles
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QPainter>
|
||||
#include <QElapsedTimer>
|
||||
#include <QColorSpace>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include <libexif/exif-data.h>
|
||||
@@ -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<typename T, typename PCLtype, int CVtype>
|
||||
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())});
|
||||
|
||||
Reference in New Issue
Block a user