Add additional colormaps

This commit is contained in:
2025-02-28 10:40:14 +01:00
parent d545c6ca0f
commit d59ee7fddc
8 changed files with 68 additions and 11 deletions
+23
View File
@@ -258,6 +258,12 @@ void ImageWidgetGL::setBayerMask(int mask)
update();
}
void ImageWidgetGL::setColormap(int colormap)
{
m_colormapIdx = colormap;
update();
}
void ImageWidgetGL::setMTFParams(const MTFParam &params)
{
m_mtfParams = params;
@@ -600,6 +606,7 @@ void ImageWidgetGL::paintGL()
m_program->setUniformValue("filtering", m_scale > 1.0f ? FILTERING : 1);
m_program->setUniformValue("lut_table", 2);
m_program->setUniformValue("srgb", m_srgb);
m_program->setUniformValue("colormapIdx", m_colormapIdx);
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
m_vao->release();
}
@@ -702,6 +709,7 @@ void ImageWidgetGL::initializeGL()
m_program->setAttributeBuffer("qt_MultiTexCoord0", GL_FLOAT, sizeof(float)*2, 2, sizeof(float)*4);
m_program->setUniformValue("qt_Texture0", (GLuint)0);
m_program->setUniformValue("lut_table", (GLuint)2);
m_program->setUniformValue("colormap", (GLuint)3);
m_program->setUniformValue("scale", 1.0f, 0.0f);
m_debayerProgram = std::unique_ptr<QOpenGLShaderProgram>(new QOpenGLShaderProgram);
@@ -764,6 +772,21 @@ void ImageWidgetGL::initializeGL()
m_lut->allocateStorage();
m_lut->bind(2);
QImage colormap(":/colormap.png");
colormap = colormap.convertToFormat(QImage::Format_RGBA8888);
qDebug() << colormap;
m_colormap = std::make_unique<QOpenGLTexture>(QOpenGLTexture::Target1DArray);
m_colormap->setSize(colormap.width());
m_colormap->setLayers(colormap.height());
m_colormap->setFormat(QOpenGLTexture::RGBA8_UNorm);
m_colormap->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
m_colormap->setWrapMode(QOpenGLTexture::ClampToEdge);
m_colormap->allocateStorage();
for(int i=0; i<colormap.height(); i++)
m_colormap->setData(0, i, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, colormap.scanLine(i));
m_colormap->bind(3);
if(m_rawImage)
setImage(m_rawImage, m_currentImg);
}