WPF图片,如何消除模糊?

Eug*_*nko 13 wpf image-processing wpf-controls

我有 在此输入图像描述

我需要 在此输入图像描述

XAML:

<Image Height="500"
       MouseLeftButtonDown="image_MouseLeftButtonDown"
       MouseRightButtonDown="image_MouseRightButtonDown"
       Name="image"
       Stretch="Fill"
       Width="500" />`
Run Code Online (Sandbox Code Playgroud)

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;
Run Code Online (Sandbox Code Playgroud)

SwD*_*n81 25

作为tkerwin提到的,改变BitmapScalingModeNearestNeighbor你XAML代码的图像:

RenderOptions.BitmapScalingMode="NearestNeighbor"
Run Code Online (Sandbox Code Playgroud)

  • @sergdev - 可以找到`RenderOptions`类[here](http://msdn.microsoft.com/en-us/library/ms635510) (2认同)

tke*_*win 15

也许您需要将位图缩放模式更改为最近邻居.

添加RenderOptions.BitmapScalingMode="NearestNeighbor"到您的图片代码.

  • 我不明白这个答案如何被认为比接受的答案更少的代码示例.那有些搞砸了.: - / (5认同)