mirror of https://github.com/Nheko-Reborn/nheko
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
740 B
31 lines
740 B
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include "ColorImageProvider.h"
|
|
|
|
#include <QPainter>
|
|
|
|
QPixmap
|
|
ColorImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &)
|
|
{
|
|
auto args = id.split('?');
|
|
|
|
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;
|
|
}
|
|
|