optionally use QQuickWidget and replace ColorOverlay -> colorImageProvider
This commit is contained in:
parent
1268e9f11c
commit
2bfb885b47
12 changed files with 197 additions and 152 deletions
30
src/ColorImageProvider.cpp
Normal file
30
src/ColorImageProvider.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "ColorImageProvider.h"
|
||||
|
||||
#include "Logging.h"
|
||||
#include <QPainter>
|
||||
|
||||
QPixmap
|
||||
ColorImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &)
|
||||
{
|
||||
auto args = id.split('?');
|
||||
|
||||
nhlog::ui()->info("Loading {}, source is {}", id.toStdString(), args[0].toStdString());
|
||||
|
||||
QPixmap source(args[0]);
|
||||
|
||||
if (size)
|
||||
*size = QSize(source.width(), source.height());
|
||||
|
||||
if (args.size() < 2)
|
||||
return source;
|
||||
|
||||
QColor color(args[1]);
|
||||
|
||||
QPixmap colorized = source;
|
||||
QPainter painter(&colorized);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
painter.fillRect(colorized.rect(), color);
|
||||
painter.end();
|
||||
|
||||
return colorized;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue