mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
22 lines
530 B
C
22 lines
530 B
C
![]() |
#include <QPixmap>
|
||
|
#include <QImageReader>
|
||
|
#include <QApplication>
|
||
|
|
||
|
namespace Utils {
|
||
|
static QPixmap renderSVG(const QString &path, const QSize &size) {
|
||
|
QImageReader reader;
|
||
|
QPixmap pixmap;
|
||
|
reader.setFileName(path);
|
||
|
if (reader.canRead()) {
|
||
|
const qreal ratio = qApp->devicePixelRatio();
|
||
|
reader.setScaledSize(size * ratio);
|
||
|
pixmap = QPixmap::fromImage(reader.read());
|
||
|
pixmap.setDevicePixelRatio(ratio);
|
||
|
}
|
||
|
else {
|
||
|
pixmap.load(path);
|
||
|
}
|
||
|
|
||
|
return pixmap;
|
||
|
}
|
||
|
}
|