blob: 71357175326d3919034597bbe2958aecca13ec1b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "ColorImageProvider.h"
#include <QIcon>
#include <QPainter>
QPixmap
ColorImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &req)
{
auto args = id.split('?');
QPixmap source(args[0]);
if (size)
*size = QSize(source.width(), source.height());
if (req.width() > 0 && req.height() > 0)
source = QIcon(args[0]).pixmap(req);
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;
}
|