Add ability to have user defined colormaps
This commit is contained in:
+24
-4
@@ -9,8 +9,10 @@
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QPainter>
|
||||
#include "imageringlist.h"
|
||||
#include <QStandardPaths>
|
||||
#include <QFloat16>
|
||||
#include <QStyle>
|
||||
#include "imageringlist.h"
|
||||
|
||||
int FILTERING = 1;
|
||||
bool OpenGLES = false;
|
||||
@@ -774,9 +776,7 @@ void ImageWidgetGL::initializeGL()
|
||||
m_lut->allocateStorage();
|
||||
m_lut->bind(2);
|
||||
|
||||
QImage colormap(":/colormap.png");
|
||||
colormap = colormap.convertToFormat(QImage::Format_RGBA8888);
|
||||
qDebug() << colormap;
|
||||
QImage colormap = loadColormap();
|
||||
m_colormap = std::make_unique<QOpenGLTexture>(QOpenGLTexture::Target1DArray);
|
||||
m_colormap->setSize(colormap.width());
|
||||
m_colormap->setLayers(colormap.height());
|
||||
@@ -970,3 +970,23 @@ void ImageWidgetGL::updateScrollBars()
|
||||
else
|
||||
emit scrollBarsUpdate(m_dx, m_width, m_imgWidth * m_scale - m_width, m_dy, m_height, m_imgHeight * m_scale - m_height);
|
||||
}
|
||||
|
||||
QImage ImageWidget::loadColormap()
|
||||
{
|
||||
QImage embedded(":/colormap.png");
|
||||
QStringList path = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
|
||||
if(path.size())
|
||||
{
|
||||
QImage user(path.first() + "/colormap.png");
|
||||
if(!user.isNull())
|
||||
{
|
||||
user = user.scaledToWidth(embedded.width(), Qt::SmoothTransformation);
|
||||
QImage tmp(embedded.width(), embedded.height() + user.height(), QImage::Format_RGBA8888);
|
||||
QPainter painter(&tmp);
|
||||
painter.drawImage(0, 0, embedded);
|
||||
painter.drawImage(0, embedded.height(), user);
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return embedded.convertToFormat(QImage::Format_RGBA8888);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user