.NET将像素转换为点并创建错误的图像大小
我有一个144像素的图像(我使用irfanView和Photoshop测量图像大小)。
但是,当使用以下xaml在窗口中打开时,由ActualWidth参数和相同图形软件测量的图像宽度为192像素。
事实证明,141点= 192像素(1pt = 1.33px)。
因此,似乎.Net打开图像,以像素为单位测量大小,并以相同的大小绘制图像。
这是代码:
<Window x:Class="test_image_resizing.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" WindowState="Maximized" Loaded="Window_Loaded">
<Grid>
<Image
x:Name="test"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Stretch="None"
Source="/test%20image%20resizing;component/Resources/Test.png" />
</Grid>
</Window>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
MessageBox.Show("test=" + test.ActualWidth.ToString());
}
没有找到相关结果
已邀请:
2 个回复
目浆搽
悲帽慑彤电