Re: [Qgis-developer] QgsMapRenderer and DPI problem

2014-09-06 Thread Martin Dobias
Hi Stefan

On Tue, Sep 2, 2014 at 1:13 PM, Ziegler Stefan stefan.zieg...@bd.so.ch wrote:

 It seems that the dpi parameter in render.setOutputSize(img.size(), dpi) is 
 not respected. For any value of dpi the line width is always the same in the 
 output raster. It it respected when using map units for line widths and not 
 milimeters, though. The script was used in an older QGIS version ages ago. So 
 I'm pretty sure it worked once. Did I miss something or is it a bug?

It looks like something is wrong with the Python bindings there. In
render() method there is optional second parameter forceWidthScale
which is interpreted incorrectly and it seems to override the DPI
settings. Even if I add /In/ annotation to it, there are still some
issues. It seems it has been broken like this probably for long time.
If you want to do map rendering with different DPI settings I would
suggest one of these options:
- use QgsMapSettings / QgsMapRendererJob - if you target 2.4 and above
- use map composer

Regards
Martin
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] QgsMapRenderer and DPI problem

2014-09-02 Thread Ziegler Stefan
Hi

I'm trying to save an image from QGIS master with python:

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()

img.save(/tmp/+filename+.png,png)


It seems that the dpi parameter in render.setOutputSize(img.size(), dpi) is not 
respected. For any value of dpi the line width is always the same in the output 
raster. It it respected when using map units for line widths and not 
milimeters, though. The script was used in an older QGIS version ages ago. So 
I'm pretty sure it worked once. Did I miss something or is it a bug?

Regards
Stefan 


Freundliche Grüsse 
Stefan Ziegler 
Kantonsgeometer 

Amt für Geoinformation
Amtliche Vermessung 
Rötistrasse 4 
4500 Solothurn 

Telefon +41 32 627 75 96
Telefax +41 32 627 75 98 
stefan.zieg...@bd.so.ch
http://www.so.ch 

___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer