1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-05 22:33:21 +02:00

Fixed PNG export ap artifacts under Qt6

This commit is contained in:
Martin Tůma 2024-09-14 10:20:14 +02:00
parent a2728b6227
commit 524ac8347f

View File

@ -686,7 +686,7 @@ void MapView::keyReleaseEvent(QKeyEvent *event)
void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
Flags flags)
{
QRect orig, adj;
QRect orig;
qreal ratio, diff, q, p;
QPointF scenePos, scalePos, posPos, motionPos;
bool hidpi = _hidpi && _deviceRatio > 1.0;
@ -699,6 +699,7 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
// Compute sizes & ratios
orig = viewport()->rect();
QRectF adj(orig);
scalePos = _mapScale->pos();
posPos = _positionCoordinates->pos();
motionPos = _motionInfo->pos();
@ -706,11 +707,11 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
ratio = target.height() / target.width();
diff = (orig.width() * ratio) - orig.height();
adj = orig.adjusted(0, -diff/2, 0, diff/2);
adj.adjust(0, -diff/2.0, 0, diff/2.0);
} else {
ratio = target.width() / target.height();
diff = (orig.height() * ratio) - orig.width();
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
adj.adjust(-diff/2.0, 0, diff/2.0, 0);
}
// Expand the view if plotting into a bitmap
@ -735,8 +736,8 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
/ (qreal)metric(QPaintDevice::PdmDpiX),
painter->device()->logicalDpiY()
/ (qreal)metric(QPaintDevice::PdmDpiY));
adj = QRect(0, 0, adj.width() * s.x(), adj.height() * s.y());
_map->zoomFit(adj.size(), _tr | _rr | _wr | _ar);
adj = QRectF(0, 0, adj.width() * s.x(), adj.height() * s.y());
_map->zoomFit(adj.size().toSize(), _tr | _rr | _wr | _ar);
rescale();
QPointF center = contentCenter();
@ -748,20 +749,20 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
p = 1 / q;
_mapScale->setDigitalZoom(_digitalZoom - log2(p));
_mapScale->setPos(mapToScene(adj.bottomRight() + QPoint(
_mapScale->setPos(mapToScene(adj.bottomRight().toPoint() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()) * p,
-(SCALE_OFFSET + _mapScale->boundingRect().height()) * p)));
_positionCoordinates->setDigitalZoom(_digitalZoom - log2(p));
_positionCoordinates->setPos(mapToScene(adj.topLeft() + QPoint(
_positionCoordinates->setPos(mapToScene(adj.topLeft().toPoint() + QPoint(
COORDINATES_OFFSET * p,
(COORDINATES_OFFSET + _positionCoordinates->boundingRect().height()) * p)));
_motionInfo->setDigitalZoom(_digitalZoom - log2(p));
_motionInfo->setPos(mapToScene(adj.topRight() + QPoint(
_motionInfo->setPos(mapToScene(adj.topRight().toPoint() + QPoint(
(-COORDINATES_OFFSET - _motionInfo->boundingRect().width()) * p,
(COORDINATES_OFFSET + _motionInfo->boundingRect().height()) * p)));
// Print the view
render(painter, target, adj);
render(painter, target, adj.toRect());
// Revert view changes to display mode
if (flags & HiRes) {