2009-04-13 144 views
2

有沒有辦法根據加載在圖像控件中的png圖像的寬度和高度獲取原始圖像大小?Silverlight:獲取圖像大小

+0

你的意思是什麼尺寸?文件大小?寬度高度? – 2009-04-14 13:13:05

+0

寬度和高度(更新了問題) – Drahcir 2009-04-14 13:35:09

回答

0

我已經下載的Silverlight 3測試版,其提供有參數,可以顯示實際圖像dimentions事件ImageOpened

0

怎麼樣 - 在你的代碼後面的文件(.xaml.cs)重新加載圖像到一個新的圖像控制,並從中取得的寬度和高度?

事情是這樣的:

System.Windows.Controls.Image img = new System.Windows.Controls.Image(); 
string UriValue = HtmlPage.Document.DocumentUri.AbsoluteUri + imagefilename; 
img.SetValue(System.Windows.Controls.Image.SourceProperty, 
     new System.Windows.Media.Imaging.BitmapImage(new Uri(UriValue))); 
double imagewidth = img.Width;