c0426ba465
* Fixes to icon generation. Generating a pixmap out of a size won't take the screen scaling factor into account, resulting in blurry results. Note that this is not a catchall solution, every case needs to be addressed manually. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * HighDpi fixes for startup splashscreen and About dialog Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Add helper function to generate appropriate pixmaps for a screen based on its dpi settings. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#include <AzCore/Casting/numeric_cast.h>
|
|
#include <AzQtComponents/Utilities/PixmapScaleUtilities.h>
|
|
|
|
#include <QtGui/private/qhighdpiscaling_p.h>
|
|
|
|
namespace AzQtComponents
|
|
{
|
|
QPixmap ScalePixmapForScreenDpi(
|
|
QPixmap pixmap, QScreen* screen, QSize size, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformationMode)
|
|
{
|
|
qreal screenDpiFactor = QHighDpiScaling::factor(screen);
|
|
pixmap.setDevicePixelRatio(screenDpiFactor);
|
|
|
|
QPixmap scaledPixmap;
|
|
|
|
size.setWidth(aznumeric_cast<int>(aznumeric_cast<qreal>(size.width()) * screenDpiFactor));
|
|
size.setHeight(aznumeric_cast<int>(aznumeric_cast<qreal>(size.height()) * screenDpiFactor));
|
|
|
|
scaledPixmap = pixmap.scaled(size, aspectRatioMode, transformationMode);
|
|
|
|
return scaledPixmap;
|
|
}
|
|
}
|