【发布时间】:2016-01-26 09:40:48
【问题描述】:
如何获取图片url的大小?
我尝试使用:
var img = new BitmapImage(new Uri(url));
img.ImageOpened += (a, d) =>
{
Debug.WriteLine("Width: {0}, Height: {1}", img.PixelWidth, img.PixelHeight);
};
Image1.Source = img;
但这并没有解决我的问题。
【问题讨论】:
-
你试过
img.Width和img.Height吗? -
是的,但是 BitmapImage 没有 Width 和 Height 属性,只有 PixelWidth、PixelHeight、DecodePixelHeight 和 DecodePixelWidth。
-
嗯...可能是因为是WP的BitmapImage...
-
你能详细说明“它不能解决我的问题”是什么意思吗?尺寸错误或为空?
-
抱歉不准确。是的,它是 WinRT BitmapImage。我得到一个空值
标签: c# windows-runtime windows-phone-8.1 windows-8.1