Bug report #11129

QgsMapRenderer does not respect DPI

Added by zicke - over 9 years ago. Updated about 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Python plugins
Affected QGIS version:master Regression?:No
Operating System:Ubuntu Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:19458

Description

The dpi parameter is not respected when exporting an image with QgsMapRenderer code below. Same code works with QGIS 1.8 (see attached files). I'm on QGIS master and Ubuntu 12.04/14.04.

img = QImage(QSize(width, height), QImage.Format_ARGB32_Premultiplied)
img.setDotsPerMeterX(dpi / 25.4 * 1000)
img.setDotsPerMeterY(dpi / 25.4 * 1000)

color = QColor(255,255,255)
img.fill(color.rgb())
p = QPainter()
p.begin(img)
p.setRenderHint(QPainter.Antialiasing)
render = QgsMapRenderer()
render.setLabelingEngine(QgsPalLabeling())
render.setLayerSet(lst)
render.setExtent(rect)
render.setOutputSize(img.size(), dpi)
render.render(p)
p.end()

QGIS_18.png (611 KB) zicke -, 2014-09-03 12:57 AM

QGIS_master.png (489 KB) zicke -, 2014-09-03 12:57 AM

History

#1 Updated by Giovanni Manghi almost 7 years ago

  • Easy fix? set to No
  • Regression? set to No

#2 Updated by Giovanni Manghi about 5 years ago

  • Resolution set to end of life
  • Status changed from Open to Closed

Also available in: Atom PDF