mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-24 16:43:59 +00:00
CoverArtBox: preserve cover art aspect ratio on drawing
Cover is now placed correctly over the cover shadow, aspect ratio is preserved.
This commit is contained in:
@@ -101,10 +101,15 @@ class CoverArtBox(QtGui.QGroupBox):
|
||||
pixmap = QtGui.QPixmap()
|
||||
pixmap.loadFromData(self.data["data"])
|
||||
if not pixmap.isNull():
|
||||
offx, offy, w, h = (1, 1, 121, 121)
|
||||
cover = QtGui.QPixmap(self.shadow)
|
||||
pixmap = pixmap.scaled(121, 121, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation)
|
||||
pixmap = pixmap.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
||||
painter = QtGui.QPainter(cover)
|
||||
painter.drawPixmap(1, 1, pixmap)
|
||||
bgcolor = QtGui.QColor.fromRgb(0, 0, 0, 128)
|
||||
painter.fillRect(QtCore.QRectF(offx, offy, w, h), bgcolor)
|
||||
x = offx + (w - pixmap.width()) / 2
|
||||
y = offy + (h - pixmap.height()) / 2
|
||||
painter.drawPixmap(x, y, pixmap)
|
||||
painter.end()
|
||||
self.coverArt.setPixmap(cover)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user