diff --git a/Telegram/SourceFiles/editor/scene/scene_item_image.cpp b/Telegram/SourceFiles/editor/scene/scene_item_image.cpp index b932b11ad8..b3cc544cfd 100644 --- a/Telegram/SourceFiles/editor/scene/scene_item_image.cpp +++ b/Telegram/SourceFiles/editor/scene/scene_item_image.cpp @@ -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); } diff --git a/Telegram/SourceFiles/editor/scene/scene_item_sticker.cpp b/Telegram/SourceFiles/editor/scene/scene_item_sticker.cpp index a60f487e0a..c678452e9e 100644 --- a/Telegram/SourceFiles/editor/scene/scene_item_sticker.cpp +++ b/Telegram/SourceFiles/editor/scene/scene_item_sticker.cpp @@ -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); }