Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Less blurry rendering of images/svg #1316

Closed
springmeyer opened this Issue · 21 comments

4 participants

@springmeyer
Owner

Raster markers that are originally pixel-fitted may not be positioned cleanly (resulting in less crisp rendering) once plotted on the map canvas because their position is done in floating point coordinates. And the same type of problem can result for SVG markers that are rendered.

For background: see #1312

Another interesting read: http://robert.ocallahan.org/2008/10/hating-pixels_13.html

@springmeyer
Owner

see also @tokumine's comments wrt to raster images and markers: #952 (comment)

@springmeyer
Owner

svg current rendering:
2_current

svg snapped to integer coords:

2_snapped

@springmeyer springmeyer referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@springmeyer
Owner

So, it looks like a good first fix is to pixel snap the location of raster markers, so that in the case of no scaling they are rendered faithfully. In the case of scaling then avoiding blurryness and keeping crisp rendering looks much more challenging and is not something I have time to understand more right now.

In the case of SVG icons the same pixel snapping of the starting location (the affine transform tx and ty) helps improve the possibility of crisp renders. But it also slightly moves the location of the markers so I think this is only warranted for complex svg's that represent stylish icons rather than simple ellipses. We cannot easily determine this, but I think a good first cut is to only pixel snap svg's loaded from files.

Some of the complexity here is summarized at https://github.com/mapnik/mapnik/wiki/Svg-rendering-gochas

@springmeyer springmeyer referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@springmeyer
Owner

2fcd531 lands in trunk what I describe above. In the future ideally we could return to this to find more ways to intelligently pixel snap when scaling. For now, closing.

@springmeyer springmeyer closed this
@tokumine

Great! thanks @springmeyer !

@Andrey-VI

Any chance to fix rendering of SVGs also for ShieldSymbolizer? ShieldSymbolizer produces unacceptable results for SVGs.
We want to switch all our icons from PNG to SVG in the near future.

/cc @artemp

@Andrey-VI

See railway stations (with no names). (Actually, icon for towns was used in this example.)
ShieldSymbolizer:
__shieldsymbolizer

MarkersSymbolizer:
__markerssymbolizer

@Andrey-VI

More impressive images. Same railway stations, but now with road shields.
ShieldSymbolizer:
__shieldsymbolizer

MarkersSymbolizer:
__markerssymbolizer

P. S.: Now I see #1849 :)

@springmeyer
Owner

@Andrey-VI - thanks for reporting. Can you try this patch? https://gist.github.com/springmeyer/5650582

@springmeyer
Owner

@Andrey-VI - whoops, updated the patch now at link above, can you try applying again fresh?

@Andrey-VI

NP.
With this patch ShieldSymbolizer's rendering looks identical with MarkersSymbolizer's. Thanks!

@springmeyer
Owner

@Andrey-VI - great. Although I see some cases where this causes more blurry images in the visual tests (with this patch). This issue overall is needs more work.

Also, I just pushed master changes into the layer-opacity branch so you should now have the fix for #1849

@springmeyer
Owner

@Andrey-VI - let's track at #1866 since this issue is closed.

@Andrey-VI
@Andrey-VI

Sorry for posting here again…
I have no success with building updated layer-opacity branch: https://gist.github.com/Andrey-VI/5c85f9948d6d7f8a57f9

@springmeyer
Owner

Do ./configure CPP_TESTS=False until I can fix this.

@springmeyer
Owner

@Andrey-VI - compile error fixed, you can pull layer-opacity again now.

@Andrey-VI

Yes, thanks again!

@PetrDlouhy PetrDlouhy referenced this issue from a commit in PetrDlouhy/mapnik
@springmeyer springmeyer pixel snap raster markers and svg files loaded from the file system -…
… partially addresses #1316
1b690fb
@strk

I'm seeing a difference in rendering SVG between 2.1 and 2.2 and this may be the cause.
Is there a way to obtain the old behavior just for the sake of getting a success during testsuite run ?

@springmeyer
Owner

No, there is no runtime switch to disable snapping. It should be easy to tweak code at compile time to disable if you care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.