在Xamarin表单中,使用C#在将图像呈现到页面之前,是否有方法获取图像源的维度?
我想根据源图像的外观,以纵向或横向方式显示图像,我唯一能想到的方法就是计算出源维度,除非有其他方法可以解决这个问题?
找到它了 here ,因为我正在使用FFImageLoading,所以可以执行以下操作:
var cachedImage = new CachedImage() { WidthRequest = 300, HeightRequest = 300, DownsampleToViewSize = true, }; cachedImage.Success += (sender, e) => { var h = e.ImageInformation.OriginalHeight; var w = e.ImageInformation.OriginalWidth; };