mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 12:38:48 +03:00
96f791daf1
See also: https://daniel.haxx.se/blog/2023/01/08/copyright-without-years/ https://hynek.me/til/copyright-years/
34 lines
785 B
C++
34 lines
785 B
C++
// 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;
|
|
}
|