cutter/src/common/HighDpiPixmap.cpp
Premade 1e6782de48
Refactor code to match new style (#3612)
* Refactor code to match coding style
* NULL to nullptr
* clang format 16
* Remove unused header
* Fix ordering of headers
* QtResImporter: Don't ignore return value of file.open()
* Add missing memory header
* GraphGridLayout: Remove <ranges>
* GraphGridLayout: no views::reverse
* Fix typos
* Console widget cmd fix
2026-05-21 14:26:49 +05:00

23 lines
651 B
C++

#include "common/HighDpiPixmap.h"
#include <QGuiApplication>
#include <QScreen>
static qreal getDevicePixelRatio(qreal devicePixelRatio)
{
if (devicePixelRatio > 0) {
return devicePixelRatio;
}
qreal ratio = 1;
for (auto screen : QGuiApplication::screens()) {
ratio = std::max(ratio, screen->devicePixelRatio());
}
return ratio;
}
HighDpiPixmap::HighDpiPixmap(int width, int height, qreal devicePixelRatio)
: QPixmap(int(width * getDevicePixelRatio(devicePixelRatio)),
int(height * getDevicePixelRatio(devicePixelRatio)))
{
setDevicePixelRatio(getDevicePixelRatio(devicePixelRatio));
}