mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-27 14:55:06 +00:00
103decedd6
* Take pixel ratio into account for graph cache.
24 lines
651 B
C++
24 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));
|
|
}
|