From 5d4f6e44d23ed76b2147176d857f5f0e8254b33e Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 14 Jul 2024 13:24:14 +1000 Subject: [PATCH] Qt: Use device pixel ratio when scaling gameicons --- src/duckstation-qt/gamelistmodel.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/duckstation-qt/gamelistmodel.cpp b/src/duckstation-qt/gamelistmodel.cpp index c1604feac..02215f5d2 100644 --- a/src/duckstation-qt/gamelistmodel.cpp +++ b/src/duckstation-qt/gamelistmodel.cpp @@ -301,13 +301,17 @@ QIcon GameListModel::getIconForGame(const QString& path) void GameListModel::fixIconPixmapSize(QPixmap& pm) { - const int width = pm.width(); - const int height = pm.height(); + const qreal dpr = pm.devicePixelRatio(); + const int width = static_cast(static_cast(pm.width()) * dpr); + const int height = static_cast(static_cast(pm.height()) * dpr); const int max_dim = std::max(width, height); if (max_dim == 16) return; - const float scale = static_cast(max_dim) / 16.0f; + const float wanted_dpr = qApp->devicePixelRatio(); + pm.setDevicePixelRatio(wanted_dpr); + + const float scale = static_cast(max_dim) / 16.0f / wanted_dpr; const int new_width = static_cast(static_cast(width) / scale); const int new_height = static_cast(static_cast(height) / scale); pm = pm.scaled(new_width, new_height);