mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Fixed scaling with width or height being 0.
This commit is contained in:
@@ -87,7 +87,7 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I
|
|||||||
if ( image.toLower().endsWith( ".svg" ) )
|
if ( image.toLower().endsWith( ".svg" ) )
|
||||||
{
|
{
|
||||||
QSvgRenderer svgRenderer( image );
|
QSvgRenderer svgRenderer( image );
|
||||||
QPixmap p( size.isNull() ? svgRenderer.defaultSize() : size );
|
QPixmap p( size.isNull() || size.height() == 0 || size.width() == 0 ? svgRenderer.defaultSize() : size );
|
||||||
p.fill( Qt::transparent );
|
p.fill( Qt::transparent );
|
||||||
|
|
||||||
QPainter pixPainter( &p );
|
QPainter pixPainter( &p );
|
||||||
@@ -117,10 +117,16 @@ ImageRegistry::pixmap( const QString& image, const QSize& size, TomahawkUtils::I
|
|||||||
|
|
||||||
if ( !size.isNull() && pixmap.size() != size )
|
if ( !size.isNull() && pixmap.size() != size )
|
||||||
{
|
{
|
||||||
Qt::AspectRatioMode aspect = Qt::IgnoreAspectRatio;
|
if ( size.width() == 0 )
|
||||||
if ( size.height() == 0 || size.width() == 0 )
|
{
|
||||||
aspect = Qt::KeepAspectRatio;
|
pixmap = pixmap.scaledToHeight( size.height(), Qt::SmoothTransformation );
|
||||||
pixmap = pixmap.scaled( size, aspect, Qt::SmoothTransformation );
|
}
|
||||||
|
else if ( size.height() == 0 )
|
||||||
|
{
|
||||||
|
pixmap = pixmap.scaledToWidth( size.width(), Qt::SmoothTransformation );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pixmap = pixmap.scaled( size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
||||||
}
|
}
|
||||||
|
|
||||||
putInCache( image, size, mode, opacity, pixmap, tint );
|
putInCache( image, size, mode, opacity, pixmap, tint );
|
||||||
|
Reference in New Issue
Block a user