Subpixel Rounding Question
Posted: 06 Mar 2019, 16:40
Hi there. Does anyone know what a good solution might be for the behavior shown below? I have a 9-grid UI which aligns layout and image pixels. I use a viewbox for scaling purposes based on target device resolution. (i.e. 100% at 1920x1080 and 200% at 4K, etc).
I am pretty sure the vertical black line shown below is caused by subpixel layout or image scaling, where scale percentage is between 100% and 200%. I like that the viewbox scales to the exact percentage needed to fill a screen identically across all devices, but I do not like the black lines that appear because of ... layout rounding?
I tried two different settings - SnapToDevicePixels (which I learned is deprecated?) and then UseLayoutRounding. Should either of these properties work for the behavior I am seeing? Are there any alternatives I might consider?
Composite Image:

Repeating Element

XAML
Thank you in advance for your consideration.
Shaun
I am pretty sure the vertical black line shown below is caused by subpixel layout or image scaling, where scale percentage is between 100% and 200%. I like that the viewbox scales to the exact percentage needed to fill a screen identically across all devices, but I do not like the black lines that appear because of ... layout rounding?
I tried two different settings - SnapToDevicePixels (which I learned is deprecated?) and then UseLayoutRounding. Should either of these properties work for the behavior I am seeing? Are there any alternatives I might consider?
Composite Image:

Repeating Element

XAML
Code: Select all
<Rectangle Width="32" HorizontalAlignment="Left" Margin="0, 41, 0, 38">
<Rectangle.Fill>
<ImageBrush ImageSource="titledwindow_left.png" Stretch="None" ViewportUnits="RelativeToBoundingBox" TileMode="Tile"/>
</Rectangle.Fill>
</Rectangle>
Thank you in advance for your consideration.
Shaun