Why isn't the image in my image control clear?

若如初见. 提交于 2020-01-06 07:12:05

问题


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".


回答1:


Try

RenderOptions.BitmapScalingMode="NearestNeighbor"

on the image control in xaml or

RenderOptions.SetBitmapScalingMode(image1, BitmapScalingMode.NearestNeighbor)

in code.




回答2:


Try SnapsToDevicePixels="True" on the image control.




回答3:


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...



来源:https://stackoverflow.com/questions/4684052/why-isnt-the-image-in-my-image-control-clear

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!