mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Fixed aspect ratio of non-standard stickers in photo editor.
This commit is contained in:
parent
b2eeab53c5
commit
e98f56b0b7
2 changed files with 14 additions and 2 deletions
|
@ -23,7 +23,13 @@ void ItemImage::paint(
|
|||
QPainter *p,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *w) {
|
||||
p->drawPixmap(contentRect().toRect(), _pixmap);
|
||||
const auto rect = contentRect();
|
||||
const auto pixmapSize = QSizeF(_pixmap.size() / style::DevicePixelRatio())
|
||||
.scaled(rect.size(), Qt::KeepAspectRatio);
|
||||
const auto resultRect = QRectF(rect.topLeft(), pixmapSize).translated(
|
||||
(rect.width() - pixmapSize.width()) / 2.,
|
||||
(rect.height() - pixmapSize.height()) / 2.);
|
||||
p->drawPixmap(resultRect.toRect(), _pixmap);
|
||||
ItemBase::paint(p, option, w);
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,13 @@ void ItemSticker::paint(
|
|||
QPainter *p,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *w) {
|
||||
p->drawImage(contentRect().toRect(), _image);
|
||||
const auto rect = contentRect();
|
||||
const auto imageSize = QSizeF(_image.size() / style::DevicePixelRatio())
|
||||
.scaled(rect.size(), Qt::KeepAspectRatio);
|
||||
const auto resultRect = QRectF(rect.topLeft(), imageSize).translated(
|
||||
(rect.width() - imageSize.width()) / 2.,
|
||||
(rect.height() - imageSize.height()) / 2.);
|
||||
p->drawImage(resultRect, _image);
|
||||
ItemBase::paint(p, option, w);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue