问题描述
我在我的 WPF 应用程序中使用了一些图像.
I'm using some Images in my WPF applcation.
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" />
但是,它们看起来很模糊.
But, they appear fuzzy.
为什么 SnapsToDevicePixels="True"
行不能防止这个问题?
Why doesn't that SnapsToDevicePixels="True"
line prevent this problem?
推荐答案
您可能需要考虑尝试 WPF4 中现在可用的新属性.将 RenderOptions.BitmapScalingMode
保留为 HighQuality 或不声明它.
You may want to consider trying a new property available now in WPF4. Leave the RenderOptions.BitmapScalingMode
to HighQuality or just don't declare it.
NearestNeighbor 对我有用,只是它在放大应用程序时会导致位图锯齿状.它似乎也没有修复图标以奇怪方式调整大小的任何故障.
NearestNeighbor worked for me except it led to jaggy bitmaps when zooming in on the application. It also didn't seem to fix any glitches where icons were sizing in weird ways.
在您的根元素(即您的主窗口)上添加此属性:UseLayoutRounding="True"
.
On your root element (i.e. your main window) add this property: UseLayoutRounding="True"
.
以前仅在 Silverlight 中可用的属性现在已修复所有位图大小问题.:)
A property previously only available in Silverlight has now fixed all Bitmap sizing woes. :)
这篇关于我的图片很模糊!为什么 WPF 的 SnapsToDevicePixels 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!