Bug report #6861

SVG symbol scaling and ouput incorrect

Added by Larry Shaffer about 12 years ago. Updated almost 12 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Symbology
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:15995

Description

This issue is to describe several SVG rendering issues currently present in 1.8 and master. I have a pull request in to fix these:

https://github.com/qgis/Quantum-GIS/pull/353/commits

The three related issues are:

A) When SVG symbol is set to map units and rendered using QPicture (e.g. when symbol is rotated) the symbol does not scale with the map item when zooming the page in or out in Print Composer. It will scale with the map item zoom, but not whole page zooming. ( see svg-sym_zoomout-of-rotated.png and svg-sym_zoomin-of-rotated.png )

I have fixed this by adding a screen-only caching of the QPicture in the same way as a QImage is cached. On output to print/image, dpi, etc. is considered as before.

B) When SVG symbol is set to map units and rendered using QPicture and the SVG viewport is not square, the symbol would be stretched to fit a square. ( see svg-sym_closeup.png and svg-sym_closeup_w-fix.png note the orange square in back is a separate layer whose non-SVG symbols are correctly sized for reference) Fixed with cached QPicture support for non-square symbols, as was already done with QImage caching.

C) Once A & B were fixed, the SVG symbol on output to print or image at a specific dpi was slightly smaller than on screen. This was more pronounced when the symbol was output at a smaller size, causing significant registration issues for symbols with overlapping labels (e.g. road shields). I fixed this by keeping the 'size' of the symbol as a double, then only casting to an integer when constructing a QImage for caching. This allowed for the output SVG (always a QPicture, using the 'size' as a double) to reasonably match what was rendered on the screen at various output zoom levels, page sizes and dpi.

svg-sym_zoomout-of-rotated.png (44.8 KB) Larry Shaffer, 2012-12-11 05:37 PM

svg-sym_zoomin-of-rotated.png (26.1 KB) Larry Shaffer, 2012-12-11 05:37 PM

svg-sym_closeup.png (25.9 KB) Larry Shaffer, 2012-12-11 05:37 PM

svg-sym_closeup_w-fix.png (34.7 KB) Larry Shaffer, 2012-12-11 05:37 PM

Associated revisions

Revision 6a936b93
Added by Larry Shaffer almost 12 years ago

Draw SVG symbol from cached QImage unless it exceeds half of cache size, then use QPicture

- Fix #6855, SVG markers/fills larger than half cache (559^2 X 32 + SVG) are drawn with QPicture
- Fix #6861, make QPicture SVG symbols scale with Composer page zoom
- Fix #6861, make SVG symbol output to print/image more accurate by setting 'size' to double
- Update/add support for non-squared SVG via QImage and QPicture, on screen and in output to print/image
- Non-squared SVG QImage/QPicture can now be used in pattern fill, without excess space

History

#1 Updated by Larry Shaffer almost 12 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF