[Qgis-developer] Map Canvas Current Zoomed Extent
bjorn.burr.nyberg at gmail.com
bjorn.burr.nyberg at gmail.com
Mon Jan 13 08:33:03 PST 2014
Related to the second portion of my question regarding getting an image of
the rendered canvas extent as an output i've tried to implement the
following as modified from the pyqgis handbook
from qgis.core import *
from qgis.gui import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtXml import *
output = r'C:\output.png'
mc = iface.mapCanvas()
rect = mc.extent()
img = QImage(QSize(800,600), QImage.Format_ARGB32_Premultiplied)
color = QColor(255,255,255)
img.fill(color.rgb())
p = QPainter()
p.begin(img)
p.setRenderHint(QPainter.Antialiasing)
render = QgsMapRenderer()
render.setExtent(rect)
render.setOutputSize(img.size(), img.logicalDpiX())
render.render(p)
p.end()
img.save(output,"png")
however the resulting image that I receive is simply a blank white image
(from the im.fill step) in addition im not entirely sure how the size of the
QImage can be related to the current extent rect?
Again any help would be appreciated,
Cheers,
Bjorn
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Map-Canvas-Current-Zoomed-Extent-tp5097678p5097818.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
More information about the Qgis-developer
mailing list