[Qgis-developer] Render with labels
Geo DrinX
geodrinx at gmail.com
Mon Oct 6 02:25:24 PDT 2014
Hello,
Sorry if I repeat my question that I sent some time ago, but it seems
very relevant
to the topic.
I noticed that using the .render() function with pyQgis > 2.2
the labels are not visible.
This is my test source code (taken from my GEarthView plugin):
iface = qgis.utils.iface
mapRenderer = mapCanvas.mapRenderer()
mapRect = mapRenderer.extent()
width = mapRenderer.width()
height = mapRenderer.height()
srs = mapRenderer.destinationCrs()
# create output image and initialize it
image = QImage(QSize(width, height), QImage.Format_ARGB32)
image.fill(0)
#adjust map canvas (renderer) to the image size and render
imagePainter = QPainter(image)
zoom = 1
target_dpi = int(round(zoom * mapRenderer.outputDpi()))
mapRenderer.setOutputSize(QSize(width, height), target_dpi)
mapRenderer.render(imagePainter)
imagePainter.end()
xN = mapRect.xMinimum()
yN = mapRect.yMinimum()
nomePNG = ("TestImage")
input_file = out_folder + "/" + nomePNG + ".png"
image.save(input_file, "png")
So, my question is : how need to change my code to have labels again
visible ?
:)
Thank you for any link and answer
Roberto
2014-10-05 22:18 GMT+02:00 Anita Graser <anitagraser at gmx.at>:
> Am 05.10.2014, 18:54 Uhr, schrieb Larry Shaffer <larrys at dakotacarto.com>:
>
>> Here's a small script you can use to test the Python bindings for labeling
>>
>
> Thanks a lot Larry! I'll give it a try!
>
> Feel free to add this to the Cookbook. However, the API for labeling may
>> change during the 2.7 dev cycle, if rule- and style-based labeling is
>> introduced.
>>
>
> You mean it will change without breaking it? ;-)
>
>
> Best wishes,
> Anita
>
>
> --
> anitagraser.com
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20141006/4d673208/attachment.html>
More information about the Qgis-developer
mailing list