WPF Image, how to remove blur?

牧云@^-^@ 提交于 2019-12-30 08:03:56

问题


I have

I need

XAML:

<Image Height="500"
       MouseLeftButtonDown="image_MouseLeftButtonDown"
       MouseRightButtonDown="image_MouseRightButtonDown"
       Name="image"
       Stretch="Fill"
       Width="500" />`

C#:

  wbmap = new WriteableBitmap(50, 50, 500, 500, PixelFormats.Indexed8, palette);
  wbmap.WritePixels(new Int32Rect(0, 0, wbmap.PixelWidth, wbmap.PixelHeight), pixels, wbmap.PixelWidth * wbmap.Format.BitsPerPixel / 8, 0);
  image.Source = wbmap;

回答1:


As tkerwin mentioned, change the BitmapScalingMode to NearestNeighbor in you XAML Image code:

RenderOptions.BitmapScalingMode="NearestNeighbor"



回答2:


Perhaps you need to change the bitmap scaling mode to nearest neighbor.

Add RenderOptions.BitmapScalingMode="NearestNeighbor" to your Image tag.




回答3:


Increase resolution / scale without anti-aliasing.

Whats happening is WPF is scaling the image but "averaging" the pixels, rather than doing a more blocky scale.

See this post:

Resize bitmap like in MS Paint



来源:https://stackoverflow.com/questions/4867173/wpf-image-how-to-remove-blur

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