WPF图像,如何去除模糊?
我有
我需要
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 tkerwin 提到的,将 BitmapScalingMode 更改为 < XAML 图像代码中的 code>NearestNeighbor :
As tkerwin mentioned, change the BitmapScalingMode to
NearestNeighbor
in you XAML Image code:也许您需要将位图缩放模式更改为最近邻居。
将
RenderOptions.BitmapScalingMode="NearestNeighbor"
添加到您的 Image 标记中。Perhaps you need to change the bitmap scaling mode to nearest neighbor.
Add
RenderOptions.BitmapScalingMode="NearestNeighbor"
to your Image tag.提高分辨率/比例而不进行抗锯齿。
发生的情况是 WPF 正在缩放图像,但“平均”像素,而不是进行更块状的缩放。
请参阅这篇文章:
像在 MS Paint 中一样调整位图大小
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