2016-02-26 12 views
1

WPF正在放大我的圖片,我正在努力弄清楚爲什麼。從this answer,我知道WPF會自動調整其元數據DPI設置與監視器DPI設置不同的圖像的大小。但是,我已確認我的圖像沒有元數據DPI設置。那麼,爲什麼WPF會調整我的圖像大小?當Stretch =「None」時,爲什麼WPF會調整沒有元數據DPI設置的圖像?

<Window x:Class="WpfApplication1.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:local="clr-namespace:WpfApplication1" 
     mc:Ignorable="d" 
     Title="MainWindow" Height="350" Width="525"> 
    <Grid> 
     <Image Source="Untitled-1.png" Stretch="None" /> 
    </Grid> 
</Window> 

回答

0

我找不到這個記錄任何地方,但經過一些實驗似乎很清楚,當圖像缺少DPI元,WPF假設圖像是由96 DPI。因此,WPF行爲的一個很好的總結是:

WPF將自動按照監視器DPI /圖像DPI的比例縮放圖像。它將讀取圖像元數據以確定圖像DPI,如果元數據不指定DPI,則WPF將使用96作爲圖像DPI。

相關問題