summaryrefslogtreecommitdiffstats
path: root/src/ColorImageProvider.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2019-11-08 14:39:45 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2019-11-23 20:06:15 +0100
commit2bfb885b4739dae46a35cfc5b1c62767b3900da9 (patch)
tree753fa8ae89671057adea30cb0e0cc53c0a4c0cf0 /src/ColorImageProvider.cpp
parent1268e9f11c22e8cd22302342e80daef94b15001d (diff)
optionally use QQuickWidget and replace ColorOverlay -> colorImageProvider
Diffstat (limited to 'src/ColorImageProvider.cpp')
-rw-r--r--src/ColorImageProvider.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ColorImageProvider.cpp b/src/ColorImageProvider.cpp
new file mode 100644
index 00000000..92e4732b
--- /dev/null
+++ b/src/ColorImageProvider.cpp
@@ -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;
+}