How can I change the interpolation mode of a WPF image?

I needed an application to show images as actual pixels when zooming in – the application was specifically for drawing pixel differences. The default WPF image however, was using some funny sampling (fant sampling, it seems), so when zoomed in, pixels became blurry soup. What I wanted was nearest neighbour sampling.

Searching the web I couldn’t find any messages saying ‘do this!’, in fact all the messages were saying ‘this feature is not yet available’. Well, it turns out that it is now available and really easy to do. Just add the property to your image like this:

<Image name="myImage" RenderOptions.BitmapScalingMode="NearestNeighbor"/>

This did exactly what I wanted. There’s a  range of other sampling modes available too, if you know what you want.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s