Make it combilable with Qt 5.13 and older
This commit is contained in:
@@ -42,6 +42,15 @@ set(TENMON_SRC
|
|||||||
stretchtoolbar.cpp
|
stretchtoolbar.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(COLOR_MANAGMENT "Enable sRGB framebuffer support for gamma correct images and color profiles support" ON)
|
||||||
|
if(${Qt5Core_VERSION_STRING} VERSION_LESS "5.14")
|
||||||
|
set(COLOR_MANAGMENT OFF)
|
||||||
|
endif(${Qt5Core_VERSION_STRING} VERSION_LESS "5.14")
|
||||||
|
|
||||||
|
if(COLOR_MANAGMENT)
|
||||||
|
add_compile_definitions("COLOR_MANAGMENT")
|
||||||
|
endif(COLOR_MANAGMENT)
|
||||||
|
|
||||||
qt5_add_resources(TENMON_SRC resources.qrc)
|
qt5_add_resources(TENMON_SRC resources.qrc)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND TENMON_SRC icon.rc)
|
list(APPEND TENMON_SRC icon.rc)
|
||||||
|
|||||||
+12
-1
@@ -24,8 +24,13 @@ const RawImageType rawImageTypes[] = {
|
|||||||
{QOpenGLTexture::Red, QOpenGLTexture::R8_UNorm, QOpenGLTexture::UInt8, true},
|
{QOpenGLTexture::Red, QOpenGLTexture::R8_UNorm, QOpenGLTexture::UInt8, true},
|
||||||
{QOpenGLTexture::Red, QOpenGLTexture::R16_UNorm, QOpenGLTexture::UInt16, true},
|
{QOpenGLTexture::Red, QOpenGLTexture::R16_UNorm, QOpenGLTexture::UInt16, true},
|
||||||
{QOpenGLTexture::Red, QOpenGLTexture::R32F, QOpenGLTexture::Float32, true},
|
{QOpenGLTexture::Red, QOpenGLTexture::R32F, QOpenGLTexture::Float32, true},
|
||||||
|
#ifdef COLOR_MANAGMENT
|
||||||
{QOpenGLTexture::RGB, QOpenGLTexture::SRGB8, QOpenGLTexture::UInt8, false},
|
{QOpenGLTexture::RGB, QOpenGLTexture::SRGB8, QOpenGLTexture::UInt8, false},
|
||||||
{QOpenGLTexture::RGBA,QOpenGLTexture::SRGB8_Alpha8, QOpenGLTexture::UInt8, false},
|
{QOpenGLTexture::RGBA,QOpenGLTexture::SRGB8, QOpenGLTexture::UInt8, false},
|
||||||
|
#else
|
||||||
|
{QOpenGLTexture::RGB, QOpenGLTexture::RGB8_UNorm, QOpenGLTexture::UInt8, false},
|
||||||
|
{QOpenGLTexture::RGBA,QOpenGLTexture::RGB8_UNorm, QOpenGLTexture::UInt8, false},
|
||||||
|
#endif
|
||||||
{QOpenGLTexture::RGB, QOpenGLTexture::RGB16_UNorm, QOpenGLTexture::UInt16, false},
|
{QOpenGLTexture::RGB, QOpenGLTexture::RGB16_UNorm, QOpenGLTexture::UInt16, false},
|
||||||
{QOpenGLTexture::RGBA, QOpenGLTexture::RGB16_UNorm, QOpenGLTexture::UInt16, false},
|
{QOpenGLTexture::RGBA, QOpenGLTexture::RGB16_UNorm, QOpenGLTexture::UInt16, false},
|
||||||
{QOpenGLTexture::RGB, QOpenGLTexture::RGB32F, QOpenGLTexture::Float32, false}
|
{QOpenGLTexture::RGB, QOpenGLTexture::RGB32F, QOpenGLTexture::Float32, false}
|
||||||
@@ -79,7 +84,9 @@ ImageWidget::ImageWidget(Database *database, QWidget *parent) : QOpenGLWidget(pa
|
|||||||
});
|
});
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
#ifdef COLOR_MANAGMENT
|
||||||
setTextureFormat(GL_SRGB8_ALPHA8);
|
setTextureFormat(GL_SRGB8_ALPHA8);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageWidget::~ImageWidget()
|
ImageWidget::~ImageWidget()
|
||||||
@@ -290,7 +297,9 @@ void ImageWidget::paintGL()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef COLOR_MANAGMENT
|
||||||
if(m_srgb)f->glEnable(GL_FRAMEBUFFER_SRGB);
|
if(m_srgb)f->glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
#endif
|
||||||
m_vao->bind();
|
m_vao->bind();
|
||||||
m_image->bind(0);
|
m_image->bind(0);
|
||||||
m_program->bind();
|
m_program->bind();
|
||||||
@@ -301,7 +310,9 @@ void ImageWidget::paintGL()
|
|||||||
m_program->setUniformValue("bw", m_bwImg);
|
m_program->setUniformValue("bw", m_bwImg);
|
||||||
m_program->setUniformValue("invert", m_invert);
|
m_program->setUniformValue("invert", m_invert);
|
||||||
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
#ifdef COLOR_MANAGMENT
|
||||||
if(m_srgb)f->glDisable(GL_FRAMEBUFFER_SRGB);
|
if(m_srgb)f->glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -5,7 +5,6 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QColorSpace>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <libexif/exif-data.h>
|
#include <libexif/exif-data.h>
|
||||||
@@ -15,7 +14,10 @@
|
|||||||
#include "starfit.h"
|
#include "starfit.h"
|
||||||
#include "wcslib/wcshdr.h"
|
#include "wcslib/wcshdr.h"
|
||||||
|
|
||||||
|
#ifdef COLOR_MANAGMENT
|
||||||
|
#include <QColorSpace>
|
||||||
static pcl::ICCProfile sRgbIccProfile((void*)QColorSpace(QColorSpace::SRgb).iccProfile().data());
|
static pcl::ICCProfile sRgbIccProfile((void*)QColorSpace(QColorSpace::SRgb).iccProfile().data());
|
||||||
|
#endif
|
||||||
|
|
||||||
LoadRunable::LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level, bool thumbnail) :
|
LoadRunable::LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level, bool thumbnail) :
|
||||||
m_file(file),
|
m_file(file),
|
||||||
@@ -293,6 +295,7 @@ bool loadPCLImage(pcl::XISFReader &xisf, RawImage **image)
|
|||||||
xisf.ReadImage(pclImage);
|
xisf.ReadImage(pclImage);
|
||||||
pclImage.Status().DisableInitialization();
|
pclImage.Status().DisableInitialization();
|
||||||
|
|
||||||
|
#ifdef COLOR_MANAGMENT
|
||||||
pcl::ICCProfile iccProfile = xisf.ReadICCProfile();
|
pcl::ICCProfile iccProfile = xisf.ReadICCProfile();
|
||||||
if(iccProfile.IsProfile())
|
if(iccProfile.IsProfile())
|
||||||
{
|
{
|
||||||
@@ -302,6 +305,7 @@ bool loadPCLImage(pcl::XISFReader &xisf, RawImage **image)
|
|||||||
iccTran.Add(sRgbIccProfile);
|
iccTran.Add(sRgbIccProfile);
|
||||||
iccTran >> pclImage;
|
iccTran >> pclImage;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int numChannels = pclImage.NumberOfChannels();
|
int numChannels = pclImage.NumberOfChannels();
|
||||||
cv::Mat cvImg[numChannels];
|
cv::Mat cvImg[numChannels];
|
||||||
@@ -401,8 +405,10 @@ void LoadRunable::run()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QImage img(m_file);
|
QImage img(m_file);
|
||||||
|
#ifdef COLOR_MANAGMENT
|
||||||
if(img.colorSpace().isValid())
|
if(img.colorSpace().isValid())
|
||||||
img.convertToColorSpace(QColorSpace::SRgb);
|
img.convertToColorSpace(QColorSpace::SRgb);
|
||||||
|
#endif
|
||||||
|
|
||||||
ExifData *exif = exif_data_new_from_file(m_file.toLocal8Bit().constData());
|
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("Width"), QString::number(img.width())});
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ int main(int argc, char *argv[])
|
|||||||
format.setMinorVersion(3);
|
format.setMinorVersion(3);
|
||||||
format.setOption(QSurfaceFormat::DebugContext);
|
format.setOption(QSurfaceFormat::DebugContext);
|
||||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||||
|
#ifdef COLOR_MANAGMENT
|
||||||
format.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
format.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
||||||
|
#endif
|
||||||
QSurfaceFormat::setDefaultFormat(format);
|
QSurfaceFormat::setDefaultFormat(format);
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user