Don't pad images in the OSD
This commit is contained in:
parent
33e61f9eb8
commit
9694977b34
@ -29,6 +29,7 @@ AlbumCoverLoader::AlbumCoverLoader(QObject* parent)
|
|||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
stop_requested_(false),
|
stop_requested_(false),
|
||||||
height_(120),
|
height_(120),
|
||||||
|
padding_(true),
|
||||||
next_id_(0),
|
next_id_(0),
|
||||||
network_(NULL)
|
network_(NULL)
|
||||||
{
|
{
|
||||||
@ -151,16 +152,19 @@ QImage AlbumCoverLoader::ScaleAndPad(const QImage &image) const {
|
|||||||
QImage copy = image.scaled(QSize(height_, height_),
|
QImage copy = image.scaled(QSize(height_, height_),
|
||||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
|
||||||
// Pad the image to height_ x height_
|
if (!padding_)
|
||||||
QImage bigger_image(height_, height_, QImage::Format_ARGB32);
|
return copy;
|
||||||
bigger_image.fill(0);
|
|
||||||
|
|
||||||
QPainter p(&bigger_image);
|
// Pad the image to height_ x height_
|
||||||
|
QImage padded_image(height_, height_, QImage::Format_ARGB32);
|
||||||
|
padded_image.fill(0);
|
||||||
|
|
||||||
|
QPainter p(&padded_image);
|
||||||
p.drawImage((height_ - copy.width()) / 2, (height_ - copy.height()) / 2,
|
p.drawImage((height_ - copy.width()) / 2, (height_ - copy.height()) / 2,
|
||||||
copy);
|
copy);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
return bigger_image;
|
return padded_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString &manual) {
|
QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString &manual) {
|
||||||
|
@ -40,6 +40,7 @@ class AlbumCoverLoader : public QObject {
|
|||||||
static QString ImageCacheDir();
|
static QString ImageCacheDir();
|
||||||
|
|
||||||
void SetDesiredHeight(int height) { height_ = height; }
|
void SetDesiredHeight(int height) { height_ = height; }
|
||||||
|
void SetPadOutputImage(bool padding) { padding_ = padding; }
|
||||||
quint64 LoadImageAsync(const QString& art_automatic, const QString& art_manual);
|
quint64 LoadImageAsync(const QString& art_automatic, const QString& art_manual);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
@ -85,6 +86,7 @@ class AlbumCoverLoader : public QObject {
|
|||||||
bool stop_requested_;
|
bool stop_requested_;
|
||||||
|
|
||||||
int height_;
|
int height_;
|
||||||
|
bool padding_;
|
||||||
|
|
||||||
QMutex mutex_;
|
QMutex mutex_;
|
||||||
QQueue<Task> tasks_;
|
QQueue<Task> tasks_;
|
||||||
|
@ -50,6 +50,7 @@ OSD::~OSD() {
|
|||||||
|
|
||||||
void OSD::CoverLoaderInitialised() {
|
void OSD::CoverLoaderInitialised() {
|
||||||
cover_loader_->Worker()->SetNetwork(network_);
|
cover_loader_->Worker()->SetNetwork(network_);
|
||||||
|
cover_loader_->Worker()->SetPadOutputImage(false);
|
||||||
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
|
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
|
||||||
SLOT(AlbumArtLoaded(quint64,QImage)));
|
SLOT(AlbumArtLoaded(quint64,QImage)));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user