2009-04-13 146 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;