@@ -60,12 +60,20 @@ QRectF QgsMapCanvasMap::boundingRect() const
60
60
61
61
void QgsMapCanvasMap::paint ( QPainter *painter )
62
62
{
63
- int w = std::round ( mItemSize .width () ) - 2 , h = std::round ( mItemSize .height () ) - 2 ; // setRect() makes the size +2 :-(
64
- if ( mImage .size () != QSize ( w, h ) )
63
+ // setRect() makes the size +2 :-(
64
+ int w = std::round ( mItemSize .width () ) - 2 ;
65
+ int h = std::round ( mItemSize .height () ) - 2 ;
66
+
67
+ bool scale = false ;
68
+ if ( mImage .size () != QSize ( w, h )*mImage .devicePixelRatioF () )
65
69
{
66
- QgsDebugMsg ( QStringLiteral ( " map paint DIFFERENT SIZE: img %1,%2 item %3,%4" ).arg ( mImage .width () ).arg ( mImage .height () ).arg ( w ).arg ( h ) );
70
+ QgsDebugMsg ( QStringLiteral ( " map paint DIFFERENT SIZE: img %1,%2 item %3,%4" )
71
+ .arg ( mImage .width () / mImage .devicePixelRatioF () )
72
+ .arg ( mImage .height () / mImage .devicePixelRatioF () )
73
+ .arg ( w ).arg ( h ) );
67
74
// This happens on zoom events when ::paint is called before
68
75
// the renderer has completed
76
+ scale = true ;
69
77
}
70
78
71
79
/* Offset between 0/0 and mRect.xMinimum/mRect.yMinimum.
@@ -83,12 +91,10 @@ void QgsMapCanvasMap::paint( QPainter *painter )
83
91
painter->drawImage ( QRectF ( ul.x (), ul.y (), lr.x () - ul.x (), lr.y () - ul.y () ), imIt->first , QRect ( 0 , 0 , imIt->first .width (), imIt->first .height () ) );
84
92
}
85
93
86
- qDebug () << " map painter: " << w << h << mImage .size () << mImage .devicePixelRatioF ();
87
- painter->drawImage ( QRect ( 0 , 0 , w, h ), mImage );
88
- // Q_ASSERT(mImage.isNull() || mImage.devicePixelRatio()==2);
89
- // QImage img = mImage;
90
- // img.setDevicePixelRatio(2);
91
- // painter->drawImage( 0,0, img );
94
+ if ( scale )
95
+ painter->drawImage ( QRect ( 0 , 0 , w, h ), mImage );
96
+ else
97
+ painter->drawImage ( 0 , 0 , mImage );
92
98
93
99
// For debugging:
94
100
#if 0
0 commit comments