Commit 0d962a00 authored by Yunhe Guo's avatar Yunhe Guo

Pixel perfect splash art rendering

When users' display settings isn't x1 or x2, make the splash art render
as exact physical pixel size. So here won't be ugly scaling that make
the splash art blur. Also make loading text sharp.
parent 68a1eb78
...@@ -50,12 +50,24 @@ KisSplashScreen::KisSplashScreen(const QString &version, const QPixmap &pixmap, ...@@ -50,12 +50,24 @@ KisSplashScreen::KisSplashScreen(const QString &version, const QPixmap &pixmap,
setupUi(this); setupUi(this);
setWindowIcon(KisIconUtils::loadIcon("krita")); setWindowIcon(KisIconUtils::loadIcon("krita"));
QImage img = pixmap.toImage(); QImage img;
if (devicePixelRatioF() > 1.01) { if (devicePixelRatioF() > 1.01) {
img = pixmap_x2.toImage(); img = pixmap_x2.toImage();
img.setDevicePixelRatio(2); img.setDevicePixelRatio(devicePixelRatioF());
// actual size : image size (x1)
m_scaleFactor = 2 / devicePixelRatioF();
} else {
img = pixmap.toImage();
m_scaleFactor = 1;
} }
setFixedWidth(pixmap.width() * m_scaleFactor);
setFixedHeight(pixmap.height() * m_scaleFactor);
lblSplash->setFixedWidth(pixmap.width() * m_scaleFactor);
lblSplash->setFixedHeight(pixmap.height() * m_scaleFactor);
QFont font = this->font(); QFont font = this->font();
font.setPointSize(11); font.setPointSize(11);
font.setBold(true); font.setBold(true);
...@@ -67,16 +79,16 @@ KisSplashScreen::KisSplashScreen(const QString &version, const QPixmap &pixmap, ...@@ -67,16 +79,16 @@ KisSplashScreen::KisSplashScreen(const QString &version, const QPixmap &pixmap,
// positioning of the text over the image (version) // positioning of the text over the image (version)
// also see setLoadingText() for positiong (loading progress text) // also see setLoadingText() for positiong (loading progress text)
int leftEdge = 475-metrics.width(version); qreal leftEdge = 475 * m_scaleFactor - metrics.width(version);
int topEdge = 58+metrics.ascent(); qreal topEdge = 58 * m_scaleFactor + metrics.ascent();
//draw shadow //draw shadow
QPen pen(QColor(0, 0, 0, 80)); QPen pen(QColor(0, 0, 0, 80));
p.setPen(pen); p.setPen(pen);
p.drawText(leftEdge+1, topEdge+1, version); p.drawText(QPointF(leftEdge+1, topEdge+1), version);
//draw main text //draw main text
p.setPen(QPen(QColor(255, 255, 255, 255))); p.setPen(QPen(QColor(255, 255, 255, 255)));
p.drawText(leftEdge, topEdge, version); p.drawText(QPointF(leftEdge, topEdge), version);
p.end(); p.end();
...@@ -86,7 +98,6 @@ KisSplashScreen::KisSplashScreen(const QString &version, const QPixmap &pixmap, ...@@ -86,7 +98,6 @@ KisSplashScreen::KisSplashScreen(const QString &version, const QPixmap &pixmap,
// Maintain the aspect ratio on high DPI screens when scaling // Maintain the aspect ratio on high DPI screens when scaling
lblSplash->setPixmap(QPixmap::fromImage(img)); lblSplash->setPixmap(QPixmap::fromImage(img));
setFixedWidth(pixmap.width());
bnClose->hide(); bnClose->hide();
connect(bnClose, SIGNAL(clicked()), this, SLOT(close())); connect(bnClose, SIGNAL(clicked()), this, SLOT(close()));
...@@ -211,16 +222,16 @@ void KisSplashScreen::setLoadingText(QString text) ...@@ -211,16 +222,16 @@ void KisSplashScreen::setLoadingText(QString text)
p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing);
// position text for loading text // position text for loading text
int leftEdge = 475-metrics.width(text); qreal leftEdge = 475 * m_scaleFactor - metrics.width(text);
int topEdge = m_textTop; qreal topEdge = m_textTop;
//draw shadow //draw shadow
QPen pen(QColor(0, 0, 0, 80)); QPen pen(QColor(0, 0, 0, 80));
p.setPen(pen); p.setPen(pen);
p.drawText(leftEdge+1, topEdge+1, text); p.drawText(QPointF(leftEdge+1, topEdge+1), text);
//draw main text //draw main text
p.setPen(QPen(QColor(255, 255, 255, 255))); p.setPen(QPen(QColor(255, 255, 255, 255)));
p.drawText(leftEdge, topEdge, text); p.drawText(QPointF(leftEdge, topEdge), text);
p.end(); p.end();
lblSplash->setPixmap(QPixmap::fromImage(img)); lblSplash->setPixmap(QPixmap::fromImage(img));
} }
......
...@@ -59,6 +59,7 @@ private: ...@@ -59,6 +59,7 @@ private:
bool m_themed; bool m_themed;
QImage m_splashImage; QImage m_splashImage;
int m_textTop; int m_textTop;
qreal m_scaleFactor;
}; };
#endif // KIS_SPLASH_SCREEN_H #endif // KIS_SPLASH_SCREEN_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment