Bug report #20038

mapCanvas.saveAsImage('path') adds a red cross to the image

Added by S Ottens about 6 years ago. Updated about 6 years ago.

Status:Closed
Priority:High
Assignee:Alessandro Pasotti
Category:Map Canvas
Affected QGIS version:3.3(master) Regression?:Yes
Operating System:Linux and Windows Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27860

Description

While exporting a series of images for an animation with the TimeManager plugin I noticed a red cross in the exported images. The red cross was put at the 0,0 coordinate regardless of the projection system used. It was not there when exported through the menu (file>export>save map as image) but only when using the TimeManager. IT did not matter if I used Linux or Windows, nor did it matter if I used QGIS 3.0, 3.2 or 3.3 At first I thought it was a bug in TimeManager and as such reported it there[[https://github.com/anitagraser/TimeManager/issues/261]].

However while going through their code I couldn't see anything that might cause the red cross to appear. So I went to the mapCanvas().saveAsImage function in QGIS and I noticed that it did have a translate function that had little to do with the map image but apparently with annotations: [[https://qgis.org/api/qgsmapcanvas_8cpp_source.html#l00767]]
That line has this function call painter.translate( itemScenePos.x(), itemScenePos.y() ); which I can easily see putting a default image at 0,0 if it doesn't have an itemScenePos but still is called for some reason. (I don't know enough C++ and/or QGIS code to really understand what is going on there).

To test this I made a very simple map of just the coastline from Natural Earth data and used the python console to export the image through the python API: [[https://twitter.com/stvno/status/1048560517277798400]]

Associated revisions

Revision 7c6cb910
Added by Alessandro Pasotti about 6 years ago

Fixes #20038 null island in canvas.saveAsImage

History

#1 Updated by Anita Graser about 6 years ago

  • Regression? changed from No to Yes
  • Priority changed from Normal to High

#2 Updated by Alessandro Pasotti about 6 years ago

  • Assignee set to Alessandro Pasotti

#3 Updated by Alessandro Pasotti about 6 years ago

  • Pull Request or Patch supplied changed from No to Yes

#4 Updated by Anonymous about 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF