问题
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