Situation
You’re building a WPF application.
Problem
Some image/bitmap is rendered blurry or pixelated.
Solution
Modify the rendering options corresponding to your needs.
Options to set on any UIElement (these are inherited by all sub-objects):
- RenderOptions.BitmapScalingMode
- UseLayoutRounding
Options to set on any image:
- SnapsToDevicePixels
A settings that has worked very well for me is UseLayoutRounding=”true”.
Sources
- http://msdn.microsoft.com/en-us/library/system.windows.media.renderoptions.bitmapscalingmode.aspx
- http://msdn.microsoft.com/de-de/library/system.windows.frameworkelement.uselayoutrounding.aspx
- http://msdn.microsoft.com/de-de/library/system.windows.uielement.snapstodevicepixels.aspx
- http://stackoverflow.com/questions/592017/my-images-are-blurry-why-isnt-wpfs-snapstodevicepixels-working
Leave a Reply