Skip to content
Snippets Groups Projects
Commit 470005c7 authored by Benjamin Arnaud's avatar Benjamin Arnaud Committed by Jean-Baptiste Kempf
Browse files

qt/covergenerator: Restore QImage::scaled implementation

QImage::scaled provides a better quality compared to QImageReader::setScaledSize.
Except for svg(s).

This implementation that was removed in a prior commit should stay relevant in the future.
parent a7cfc5d5
No related branches found
No related tags found
1 merge request!2083qt/covergenerator: Restore QImage::scaled implementation
Pipeline #233161 passed with stage
in 18 minutes and 24 seconds
......@@ -234,8 +234,31 @@ void CoverGenerator::drawImage(QPainter & painter, const QString & fileName, con
QSize size = reader.size().scaled(target.width(),
target.height(), Qt::KeepAspectRatioByExpanding);
reader.setScaledSize(size);
QImage image = reader.read();
QImage image;
// NOTE: QImage::scaled provides a better quality compared to QImageReader::setScaledSize.
// Except for svg(s).
if (fileName.endsWith(".svg", Qt::CaseInsensitive))
{
if (size.isEmpty() == false)
{
reader.setScaledSize(size);
}
if (reader.read(&image) == false)
return;
}
else
{
if (reader.read(&image) == false)
return;
if (size.isEmpty() == false)
{
// NOTE: We are using Qt::SmoothTransformation to favor quality.
image = image.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
}
int x = std::ceil((image.width() - target.width()) / 2.);
int y = std::ceil((image.height() - target.height()) / 2.);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment