[imgur 删除图片]
左侧的图标是此代码的结果:
<Button Height="23" HorizontalAlignment="Left" Margin="12,276,0,0" Name="button1" VerticalAlignment="Top" Width="75">
<StackPanel Orientation="Horizontal">
<Image Source="Resources/add.png" Stretch="None" />
<TextBlock Margin="5,0,0,0" Text="Add" />
</StackPanel>
</Button>
右侧是使用 Photoshop 放置在其旁边的原始图像。看起来通过代码添加的像素被像素拉伸(stretch),导致一些失真。我该如何防止这种情况发生?
最佳答案
Stretch="None"
应该做到这一点。如果图像的显示方式存在差异,则可能是由于像素最终“位于边缘”所致。
您可以尝试设置SnapsToDevicePixels
="True"
以避免这种情况。
关于wpf - 如何让图像不拉伸(stretch)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5845200/