diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.cpp b/src/libtomahawk/utils/TomahawkUtilsGui.cpp index dbc523d48..0ff7dd7f7 100644 --- a/src/libtomahawk/utils/TomahawkUtilsGui.cpp +++ b/src/libtomahawk/utils/TomahawkUtilsGui.cpp @@ -947,6 +947,21 @@ squareCenterPixmap( const QPixmap& sourceImage ) } +QPixmap +tinted( const QPixmap& p, const QColor& tint ) +{ + QImage resultImage( p.size(), QImage::Format_ARGB32_Premultiplied ); + QPainter painter( &resultImage ); + painter.drawPixmap( 0, 0, p ); + painter.setCompositionMode( QPainter::CompositionMode_Screen ); + painter.fillRect( resultImage.rect(), tint ); + painter.end(); + + resultImage.setAlphaChannel( p.toImage().alphaChannel() ); + return QPixmap::fromImage( resultImage ); +} + + QImage blurred( const QImage& image, const QRect& rect, int radius, bool alphaOnly, bool blackWhite ) { diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.h b/src/libtomahawk/utils/TomahawkUtilsGui.h index 33e904ca3..c9232d073 100644 --- a/src/libtomahawk/utils/TomahawkUtilsGui.h +++ b/src/libtomahawk/utils/TomahawkUtilsGui.h @@ -76,6 +76,7 @@ namespace TomahawkUtils DLLEXPORT QPixmap addDropShadow( const QPixmap& sourceImage, const QSize& targetSize ); DLLEXPORT QPixmap squareCenterPixmap( const QPixmap& sourceImage ); + DLLEXPORT QPixmap tinted( const QPixmap& pixmap, const QColor& tint ); DLLEXPORT QImage blurred( const QImage& image, const QRect& rect, int radius, bool alphaOnly = false, bool blackWhite = false ); DLLEXPORT void drawCompositedPopup( QWidget* widget, const QPainterPath& outline, const QColor& lineColor, const QBrush& backgroundBrush, qreal opacity );