代码之家  ›  专栏  ›  技术社区  ›  DarkW1nter

xamarin形式.用c计算图像源的尺寸#

  •  0
  • DarkW1nter  · 技术社区  · 6 年前

    在Xamarin表单中,使用C#在将图像呈现到页面之前,是否有方法获取图像源的维度?

    我想根据源图像的外观,以纵向或横向方式显示图像,我唯一能想到的方法就是计算出源维度,除非有其他方法可以解决这个问题?

    1 回复  |  直到 6 年前
        1
  •  0
  •   DarkW1nter    6 年前

    找到它了 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; };