0

I have a class derived from Image, to which I set the Source to a BitmapSource and override the OnRender(DrawingContext dc) method so I can overlay the image with some info.

What I want to do is to render this BitmapSource with no interpolation, so the original image's pixel boundaries are apparent when zoomed into. But I could not find any property of the DrawingContext that would allow me to set the interpolation mode for bitmaps.

How can I accomplish that?

HericDenis
  • 1,364
  • 12
  • 28
  • Set RenderOptions.BitmapScalingMode to NearestNeighbor in the Image element. – Clemens Nov 23 '21 at 15:42
  • @Clemens, thanks for the comment! Exactly which object has this property? Or how can I get the RenderOptions object related to this Image / DrawingContext? – HericDenis Nov 23 '21 at 15:49
  • It's an attached property that you would set on the Image. – Clemens Nov 23 '21 at 15:52
  • Oh, great! I can do it from XAML like this then: RenderOptions.BitmapScalingMode="NearestNeighbor". It works! You can submit that as an answer and I'll accept it. If you don't want to I will post it myself. Might be useful for someone else. – HericDenis Nov 23 '21 at 15:59

0 Answers0