mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 19:31:02 +01:00
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),
|
||||
stop_requested_(false),
|
||||
height_(120),
|
||||
padding_(true),
|
||||
next_id_(0),
|
||||
network_(NULL)
|
||||
{
|
||||
@ -151,16 +152,19 @@ QImage AlbumCoverLoader::ScaleAndPad(const QImage &image) const {
|
||||
QImage copy = image.scaled(QSize(height_, height_),
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
// Pad the image to height_ x height_
|
||||
QImage bigger_image(height_, height_, QImage::Format_ARGB32);
|
||||
bigger_image.fill(0);
|
||||
if (!padding_)
|
||||
return copy;
|
||||
|
||||
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,
|
||||
copy);
|
||||
p.end();
|
||||
|
||||
return bigger_image;
|
||||
return padded_image;
|
||||
}
|
||||
|
||||
QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString &manual) {
|
||||
|
@ -40,6 +40,7 @@ class AlbumCoverLoader : public QObject {
|
||||
static QString ImageCacheDir();
|
||||
|
||||
void SetDesiredHeight(int height) { height_ = height; }
|
||||
void SetPadOutputImage(bool padding) { padding_ = padding; }
|
||||
quint64 LoadImageAsync(const QString& art_automatic, const QString& art_manual);
|
||||
|
||||
void Clear();
|
||||
@ -85,6 +86,7 @@ class AlbumCoverLoader : public QObject {
|
||||
bool stop_requested_;
|
||||
|
||||
int height_;
|
||||
bool padding_;
|
||||
|
||||
QMutex mutex_;
|
||||
QQueue<Task> tasks_;
|
||||
|
@ -50,6 +50,7 @@ OSD::~OSD() {
|
||||
|
||||
void OSD::CoverLoaderInitialised() {
|
||||
cover_loader_->Worker()->SetNetwork(network_);
|
||||
cover_loader_->Worker()->SetPadOutputImage(false);
|
||||
connect(cover_loader_->Worker().get(), SIGNAL(ImageLoaded(quint64,QImage)),
|
||||
SLOT(AlbumArtLoaded(quint64,QImage)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user