mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-19 04:02:09 +01:00
Fixed multiple HiDPI map render issues
This commit is contained in:
parent
fe70b31212
commit
f7f680b93e
@ -7,7 +7,8 @@
|
|||||||
static QImage img2line(const QImage &img, int width)
|
static QImage img2line(const QImage &img, int width)
|
||||||
{
|
{
|
||||||
Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied);
|
Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied);
|
||||||
QImage res(width, img.height(), QImage::Format_ARGB32_Premultiplied);
|
QImage res(width * img.devicePixelRatio(), img.height(),
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
const int srcBpl = img.bytesPerLine();
|
const int srcBpl = img.bytesPerLine();
|
||||||
const int dstBpl = res.bytesPerLine();
|
const int dstBpl = res.bytesPerLine();
|
||||||
const uchar *srcBits = img.bits();
|
const uchar *srcBits = img.bits();
|
||||||
@ -21,6 +22,8 @@ static QImage img2line(const QImage &img, int width)
|
|||||||
memcpy(dstLine, srcLine, qMin(j, srcBpl));
|
memcpy(dstLine, srcLine, qMin(j, srcBpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.setDevicePixelRatio(img.devicePixelRatio());
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,15 +294,16 @@ void TextPathItem::init(const T &line, const QRect &tileRect)
|
|||||||
if (label && _img) {
|
if (label && _img) {
|
||||||
cw = _font->pixelSize() * CHAR_RATIO;
|
cw = _font->pixelSize() * CHAR_RATIO;
|
||||||
mw = _font->pixelSize() / 2.0;
|
mw = _font->pixelSize() / 2.0;
|
||||||
textWidth = _text->size() * cw + _img->width() + PADDING;
|
textWidth = _text->size() * cw
|
||||||
|
+ (_img->width() / _img->devicePixelRatioF()) + PADDING;
|
||||||
} else if (label) {
|
} else if (label) {
|
||||||
cw = _font->pixelSize() * CHAR_RATIO;
|
cw = _font->pixelSize() * CHAR_RATIO;
|
||||||
mw = _font->pixelSize() / 2.0;
|
mw = _font->pixelSize() / 2.0;
|
||||||
textWidth = _text->size() * cw;
|
textWidth = _text->size() * cw;
|
||||||
} else {
|
} else {
|
||||||
cw = _img->width();
|
cw = _img->width() / _img->devicePixelRatioF();
|
||||||
mw = _img->height() / 2.0;
|
mw = _img->height() / _img->devicePixelRatioF() / 2.0;
|
||||||
textWidth = _img->width();
|
textWidth = _img->width() / _img->devicePixelRatioF();
|
||||||
}
|
}
|
||||||
|
|
||||||
_path = textPath(line, textWidth, cw, tileRect.adjusted(mw, mw, -mw, -mw));
|
_path = textPath(line, textWidth, cw, tileRect.adjusted(mw, mw, -mw, -mw));
|
||||||
@ -358,7 +359,8 @@ void TextPathItem::paint(QPainter *painter) const
|
|||||||
if (_text && _font) {
|
if (_text && _font) {
|
||||||
QFontMetrics fm(*_font);
|
QFontMetrics fm(*_font);
|
||||||
int textWidth = fm.boundingRect(*_text).width();
|
int textWidth = fm.boundingRect(*_text).width();
|
||||||
int imgWidth = _img ? _img->width() + PADDING : 0;
|
int imgWidth = _img
|
||||||
|
? (_img->width() / _img->devicePixelRatioF()) + PADDING : 0;
|
||||||
qreal imgPercent = imgWidth / _path.length();
|
qreal imgPercent = imgWidth / _path.length();
|
||||||
qreal factor = textWidth / qMax(_path.length(), (qreal)(textWidth));
|
qreal factor = textWidth / qMax(_path.length(), (qreal)(textWidth));
|
||||||
qreal percent = ((1.0 - factor) + imgPercent) / 2.0;
|
qreal percent = ((1.0 - factor) + imgPercent) / 2.0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user