Enable sRGB to gamma correct scaling
This commit is contained in:
@@ -24,8 +24,8 @@ const RawImageType rawImageTypes[] = {
|
||||
{QOpenGLTexture::Red, QOpenGLTexture::R8_UNorm, QOpenGLTexture::UInt8, true},
|
||||
{QOpenGLTexture::Red, QOpenGLTexture::R16_UNorm, QOpenGLTexture::UInt16, true},
|
||||
{QOpenGLTexture::Red, QOpenGLTexture::R32F, QOpenGLTexture::Float32, true},
|
||||
{QOpenGLTexture::RGB, QOpenGLTexture::RGB8_UNorm, QOpenGLTexture::UInt8, false},
|
||||
{QOpenGLTexture::RGBA,QOpenGLTexture::RGB8_UNorm, QOpenGLTexture::UInt8, false},
|
||||
{QOpenGLTexture::RGB, QOpenGLTexture::SRGB8, QOpenGLTexture::UInt8, false},
|
||||
{QOpenGLTexture::RGBA,QOpenGLTexture::SRGB8_Alpha8, QOpenGLTexture::UInt8, false},
|
||||
{QOpenGLTexture::RGB, QOpenGLTexture::RGB16_UNorm, QOpenGLTexture::UInt16, false},
|
||||
{QOpenGLTexture::RGBA, QOpenGLTexture::RGB16_UNorm, QOpenGLTexture::UInt16, false},
|
||||
{QOpenGLTexture::RGB, QOpenGLTexture::RGB32F, QOpenGLTexture::Float32, false}
|
||||
@@ -79,6 +79,7 @@ ImageWidget::ImageWidget(Database *database, QWidget *parent) : QOpenGLWidget(pa
|
||||
});
|
||||
|
||||
setMouseTracking(true);
|
||||
setTextureFormat(GL_SRGB8_ALPHA8);
|
||||
}
|
||||
|
||||
ImageWidget::~ImageWidget()
|
||||
@@ -110,6 +111,7 @@ void ImageWidget::setImage(std::shared_ptr<RawImage> image, int index)
|
||||
m_image->setLevelOfDetailRange(m_superpixel ? 1 : 0, m_image->mipMaxLevel());
|
||||
m_image->generateMipMaps();
|
||||
m_bwImg = rawImageType.bw;
|
||||
m_srgb = rawImageType.textureFormat == QOpenGLTexture::SRGB8 || rawImageType.textureFormat == QOpenGLTexture::SRGB8_Alpha8;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -288,6 +290,7 @@ void ImageWidget::paintGL()
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_srgb)f->glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
m_vao->bind();
|
||||
m_image->bind(0);
|
||||
m_program->bind();
|
||||
@@ -298,6 +301,7 @@ void ImageWidget::paintGL()
|
||||
m_program->setUniformValue("bw", m_bwImg);
|
||||
m_program->setUniformValue("invert", m_invert);
|
||||
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
if(m_srgb)f->glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user