0
BitmapImage B = new BitmapImage();
B.BeginInit();
B.StreamSource = asm.GetManifestResourceStream("WpfApplication26.Back1.png");
B.EndInit();
image1.Source = B;

The size of the image (Back1.png) is 32*32, and I set the size of my image control to 32*32 and set the property "Scale" to "None".

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
vmahdavi
  • 399
  • 1
  • 4
  • 9

3 Answers3

1

Try

RenderOptions.BitmapScalingMode="NearestNeighbor"

on the image control in xaml or

RenderOptions.SetBitmapScalingMode(image1, BitmapScalingMode.NearestNeighbor)

in code.

Andrei Pana
  • 4,484
  • 1
  • 26
  • 27
0

Try SnapsToDevicePixels="True" on the image control.

Kent Boogaart
  • 175,602
  • 35
  • 392
  • 393
0

If you still want to clear the image, meaning, turning it to blank, just set the source to "null"

image1.Source = null;

This does not require a BitmapImage.

Sorry for the late reply...

Pimenta
  • 1,029
  • 2
  • 13
  • 32