mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-31 10:00:46 +03:00
28 lines
640 B
C++
28 lines
640 B
C++
|
#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;
|
||
|
}
|