我在WPF应用程序中使用了一些图像。
XAML:
<Image Name="ImageOrderedList"
Source="images/OrderedList.png"
ToolTip="Ordered List"
Margin="0,0,5,5"
Width="20"
Height="20"
SnapsToDevicePixels="True"
MouseUp="Image_MouseUp"
MouseEnter="Image_MouseEnter"
MouseLeave="Image_MouseLeave" />
但是,它们看起来很模糊。
为什么SnapsToDevicePixels="True"
行不能防止这个问题呢?
发布于 2009-02-26 21:33:54
我用的不是SnapsToDevicePixels
,而是RenderOptions.BitmapScalingMode
,它们现在又好又干净利落!
XAML:
<Image Name="ImageOrderedList"
Source="images/OrderedList.png"
ToolTip="Ordered List"
Margin="0,0,5,5"
Width="20"
Height="20"
RenderOptions.BitmapScalingMode="NearestNeighbor"
MouseUp="Image_MouseUp"
MouseEnter="Image_MouseEnter"
MouseLeave="Image_MouseLeave" />
发布于 2010-05-04 22:24:21
扎克·彼得森+1
我使用的是.Net 3.5 sp1,它看起来是处理大量模糊图像的最简单的解决方案。就地指定RenderOptions并不是什么大问题,但对于第三方组件来说,应用级资源中的样式是有意义的:
<Style TargetType="{x:Type Image}">
<Setter
Property="RenderOptions.BitmapScalingMode"
Value="NearestNeighbor" />
</Style>
当AvalonDock开始渲染模糊图标时,效果很好。
发布于 2009-04-06 20:22:45
RenderOptions.BitmapScalingMode="NearestNeighbor“在大多数情况下都工作得很好。然而,偶尔你会遇到图形故障(在我的例子中,5个图像中有4个显示得很好,但第五个图像在右边有轻微的失真)。我把Image控件的右边距增加了1,解决了这个问题。
如果仍然不能修复它,请尝试EugeneZ提到的上面的Bitmap类控件。它是Image控件的替代品,到目前为止,它对我来说工作得很好。请参阅http://blogs.msdn.com/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx
https://stackoverflow.com/questions/592017
复制相似问题