locked
Pixel Positioning not 100% Accurate

    Question

  • Hi there,

    I'm making a rather crude tiled image control that uses a grid to position image objects next to each other so that the area is covered.  In the designer it looks fine, but when run, after about the 6th image there is a visible 1 pixel thick empty line which just shouldn't exist.

    I have a sample of the code here,

    http://npsoftware.s3.amazonaws.com/code/tilebrushtest.zip

    The underlying control is calculated in whole units only, which should't cause an issue.  I originally tried a canvas control but that was much worse.

    http://npsoftware.s3.amazonaws.com/code/1.jpg

    ^designtime

    http://npsoftware.s3.amazonaws.com/code/2.jpg

    ^ runtime

    It's almost as if the app isn't running at 100% of its size, it's like 99% of it's size, stretching the grid...


    Somewhere out there...

    Friday, April 25, 2014 1:19 PM

Answers

  • Hello,

    With certain devices DPI scaling can occur. When DPI scaling occurs you can get rounding errors that can add up and prevent pixel perfect display of XAML elements. If you need pixel perfect display of your elements you should use a more accurate technology such as Direct2D. Direct2D uses device independent units that can then be more accurately scaled to high DPI devices.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Saturday, April 26, 2014 12:38 AM
    Moderator