@@ -313,6 +313,7 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn
313
313
job.cached = true ;
314
314
job.imageInitialized = true ;
315
315
job.img = new QImage ( mCache ->cacheImage ( ml->id () ) );
316
+ job.img ->setDevicePixelRatio ( mSettings .devicePixelRatio () );
316
317
job.renderer = nullptr ;
317
318
job.context .setPainter ( nullptr );
318
319
continue ;
@@ -324,10 +325,9 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn
324
325
if ( mCache || !painter || needTemporaryImage ( ml ) )
325
326
{
326
327
// Flattened image for drawing when a blending mode is set
327
- QImage *mypFlattenedImage = nullptr ;
328
- mypFlattenedImage = new QImage ( mSettings .outputSize ().width (),
329
- mSettings .outputSize ().height (),
330
- mSettings .outputImageFormat () );
328
+ QImage *mypFlattenedImage = new QImage ( mSettings .deviceOutputSize (),
329
+ mSettings .outputImageFormat () );
330
+ mypFlattenedImage->setDevicePixelRatio ( mSettings .devicePixelRatio () );
331
331
if ( mypFlattenedImage->isNull () )
332
332
{
333
333
mErrors .append ( Error ( ml->id (), tr ( " Insufficient memory for image %1x%2" ).arg ( mSettings .outputSize ().width () ).arg ( mSettings .outputSize ().height () ) ) );
@@ -366,6 +366,7 @@ LabelRenderJob QgsMapRendererJob::prepareLabelingJob( QPainter *painter, QgsLabe
366
366
job.cached = true ;
367
367
job.complete = true ;
368
368
job.img = new QImage ( mCache ->cacheImage ( LABEL_CACHE_ID ) );
369
+ Q_ASSERT ( job.img ->devicePixelRatio () == mSettings .devicePixelRatio () );
369
370
job.context .setPainter ( nullptr );
370
371
}
371
372
else
@@ -374,9 +375,9 @@ LabelRenderJob QgsMapRendererJob::prepareLabelingJob( QPainter *painter, QgsLabe
374
375
{
375
376
// Flattened image for drawing labels
376
377
QImage *mypFlattenedImage = nullptr ;
377
- mypFlattenedImage = new QImage ( mSettings .outputSize ().width (),
378
- mSettings .outputSize ().height (),
378
+ mypFlattenedImage = new QImage ( mSettings .deviceOutputSize (),
379
379
mSettings .outputImageFormat () );
380
+ mypFlattenedImage->setDevicePixelRatio ( mSettings .devicePixelRatio () );
380
381
if ( mypFlattenedImage->isNull () )
381
382
{
382
383
mErrors .append ( Error ( QStringLiteral ( " labels" ), tr ( " Insufficient memory for label image %1x%2" ).arg ( mSettings .outputSize ().width () ).arg ( mSettings .outputSize ().height () ) ) );
@@ -447,7 +448,8 @@ void QgsMapRendererJob::cleanupLabelJob( LabelRenderJob &job )
447
448
448
449
QImage QgsMapRendererJob::composeImage ( const QgsMapSettings &settings, const LayerRenderJobs &jobs, const LabelRenderJob &labelJob )
449
450
{
450
- QImage image ( settings.outputSize (), settings.outputImageFormat () );
451
+ QImage image ( settings.deviceOutputSize (), settings.outputImageFormat () );
452
+ image.setDevicePixelRatio ( settings.devicePixelRatio () );
451
453
image.fill ( settings.backgroundColor ().rgba () );
452
454
453
455
QPainter painter ( &image );
0 commit comments