This project has moved and is read-only. For the latest updates, please go here.

subpixel rendering

Mar 11, 2015 at 7:17 PM
Hi Clemens

I have somewhat of a cosmetic issue with items on the map control and was wondering if you might know a simple way to solve this: I have a ControlTemplate for my MapItems which is a 1-Pixel white border with a black rectangle inside (for the sake of simplicity and to illustrate the issue). The XAML is as follows:
<ControlTemplate TargetType="map:MapItem">
    <Border BorderBrush="White" BorderThickness="1">
        <Rectangle Width="100" Height="100" Fill="Black"/>
When I place several of these on my map and zoom in and out then some of the 1-pixel borders fall in between pixels and are not clear white anymore but due to subpixel rendering (I suppose) become kind of greyish.
Do you know of any way to make sure that MapItems are always on and never in between pixels when zooming so subpixel rendering never happens?

Thanks for your help! Regards, blomquist
Mar 11, 2015 at 8:00 PM
If the question is about WPF, you could set the Border's SnapsToDevicePixels property:
<Border BorderBrush="White" BorderThickness="1" SnapsToDevicePixels="True">
Mar 12, 2015 at 11:56 AM
Thanks very much for the fast reply! Actually this would be exactly what I need if I were using WPF. However, I'm on WinRT and there is no SnapsToDevicePixels property. I have experimented with setting UseLayoutRounding to true (which it should be by default) but it has no visual effect and I still get blurry lines. I understand that SnapsToDevicePixels happens during the rendering phase whereas UseLayoutRounding only happens during the layout phase. Do you know if the layout of MapItems is updated at all when I zoom the map in or out so the property would even have an effect at all? Or maybe you could tell me that it's simply not possible, then I could stop looking for a solution and deal with the problem some other way. Any help is deeply appreciated!

Thanks very much. Kind regards, blomquist
Mar 12, 2015 at 12:25 PM
Edited Mar 12, 2015 at 12:27 PM
For performance reasons, MapItems (or better all children of a MapPanel with a MapPanel.Location) are positioned by a RenderTransform. So layout rounding will have no effect.

It should however be possible that MapPanel takes the value of the UseLayoutRounding property into account when the RenderTransform is calculated. I'll take a look into that.

I admit that I never realize this kind of visual effect since I own a notebook with 3200x1600 screen resolution :-)
Mar 15, 2015 at 10:43 AM
Please check out the latest release. MapPanel now implements the UseLayoutRounding property.

You may set the property in a MapItem style like this:
<Style ... TargetType="map:MapItem">
    <Setter Property="UseLayoutRounding" Value="True"/>
Mar 15, 2015 at 6:42 PM
Simply Fantastic!! Thank you so much!