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.

Advertisements

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s