BitmapImage B = new BitmapImage();
B.BeginInit();
B.StreamSource = asm.GetManifestResourceStream("WpfApplication26.Back1.png");
B.EndInit();
image1.Source = B;
图片(Back1.png)的大小为32*32,我将图片控件的大小设置为32*32,并将属性“Scale”设置为“None”。
BitmapImage B = new BitmapImage();
B.BeginInit();
B.StreamSource = asm.GetManifestResourceStream("WpfApplication26.Back1.png");
B.EndInit();
image1.Source = B;
图片(Back1.png)的大小为32*32,我将图片控件的大小设置为32*32,并将属性“Scale”设置为“None”。
尝试
RenderOptions.BitmapScalingMode="NearestNeighbor"
在 xaml 中的图像控件上或
RenderOptions.SetBitmapScalingMode(image1, BitmapScalingMode.NearestNeighbor)
在代码中。
试试SnapsToDevicePixels="True"
图像控制。
如果您仍然想清除图像,意思是将其变为空白,只需将源设置为“null”
image1.Source = null;
这不需要 BitmapImage。
这么晚才回复很抱歉...