QGIS composer "output to a raster file"

المشرف العام

Administrator
طاقم الإدارة
According to QGIS page, if I want to layout a map and export to raster:

dpi = c.printResolution()dpmm = dpi / 25.4width = int(dpmm * c.paperWidth())height = int(dpmm * c.paperHeight())# create output image and initialize itimage = QImage(QSize(width, height), QImage.Format_ARGB32)image.setDotsPerMeterX(dpmm * 1000)image.setDotsPerMeterY(dpmm * 1000)image.fill(0)# render the compositionimagePainter = QPainter(image)sourceArea = QRectF(0, 0, c.paperWidth(), c.paperHeight())targetArea = QRectF(0, 0, width, height)c.render(imagePainter, targetArea, sourceArea)imagePainter.end()image.save("out.png", "png")But when I try with that, I have this error:

QPainter::begin: Paint device returned engine == 0, type: 3 QPainter::end: Painter not active, abortedWhat is wrong? I have success whrn I use a template predefined but I want to create a template according to each map.



أكثر...
 
أعلى