Image in WPF getting Blurry Image in WPF getting Blurry wpf wpf

Image in WPF getting Blurry


I think what Markus told is the one way to resolve your issue and try by adding one more property in it RenderOptions.EdgeMode="Aliased" for each image I mean :

<Image Source="/LoginPanel;component/Icons/icoLogin.ico"       RenderOptions.BitmapScalingMode="NearestNeighbor"       RenderOptions.EdgeMode="Aliased"/>

if you still not able to fix your problem then you can refer this http://blogs.msdn.com/b/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx to create a custom Bitmap class and apply on all Images which are creating trouble for you.

You can also see this Stack Overflow Question


SnapsToDevicePixels seems not working for bitmaps.

The NearestNeighbor options actually converts the bitmap and will end up with different one to the original bitmap.

In WPF 4, a property "UseLayoutRounding" on the FrameworkElement is introduced to solve this problem.

By setting this property to True on your root element, such as Window will align children elements on the edges of pixels.

<Window UseLayoutRounding="True">...</Window>


This works for me

<Image Source="/LoginPanel;component/Icons/icoLogin.ico"       RenderOptions.BitmapScalingMode="NearestNeighbor"</Image>

Set RenderOptions.BitmapScalingMode="NearestNeighbor" for each image. Alternatively see this question here on StackOverflow.

Edit:
Here is my sample code

<Window x:Class="MainWindow"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    Title="MainWindow" Height="350" Width="661">    <WrapPanel>        <Button VerticalAlignment="Center">            <Image Source="/WpfApplication1;component/icoChip32x32.ico"               RenderOptions.BitmapScalingMode="NearestNeighbor" Stretch="None"></Image>        </Button>        <Button VerticalAlignment="Center">            <Image Source="/WpfApplication1;component/icoChip32x32.ico"                   RenderOptions.BitmapScalingMode="NearestNeighbor" Stretch="None"></Image>        </Button>        <Button VerticalAlignment="Center">            <Image Source="/WpfApplication1;component/Presentation-Edit.png"               RenderOptions.BitmapScalingMode="NearestNeighbor" Stretch="None"></Image>        </Button>        <Button VerticalAlignment="Center">            <Image Source="/WpfApplication1;component/Presentation-Edit.png"                   RenderOptions.BitmapScalingMode="NearestNeighbor" Stretch="None"></Image>        </Button>    </WrapPanel></Window>

And this is my result:
...and this is my result