【问题标题】:How to reuse cached result in the FFImageLoading on Xamarin.Forms?如何在 Xamarin.Forms 上的 FFImageLoading 中重用缓存的结果?
【发布时间】:2017-11-28 02:29:49
【问题描述】:

我正在尝试在加载应用程序主数据时在后台加载、调整大小和转换图像。我需要这样做,因为有些图像太大而且我有很多,所以,我认为最好在展示之前准备好所有图像。

我在后台执行这段代码: 从 Uri 加载图像:

ImageService.Instance.LoadUrl(uri, TimeSpan.FromDays(60))
            .DownSample(100, 100, false).Preload();

加载相同的图像并对其应用额外的转换:

ImageService.Instance.LoadUrl(uri, TimeSpan.FromDays(60))
            .DownSample(100, 100, false).Transform(BlurredTransformHere).Preload();

我以后如何在 CachedImage 中重用这些缓存查询的结果?

 <forms:CachedImage
    x:Name="Blured"
    Aspect="Fill"
    CacheType="All"
    HorizontalOptions="Fill"
    Opacity="0.3"
    VerticalOptions="Fill"/>     

 <forms:CachedImage
    x:Name="Normal"
    CacheType="All"
    Aspect="AspectFit"
    HorizontalOptions="CenterAndExpand"
    VerticalOptions="CenterAndExpand"/>

我应该为每个 CachedImage 添加与查询中相同的配置参数吗?例如添加具有相同参数值的 DownsampleHeight&W 和 BlurredTransformation?

【问题讨论】:

    标签: xamarin xamarin.forms ffimageloading


    【解决方案1】:

    转换不会影响图像的缓存版本,它们只会改变图像源的呈现方式。

    对于图像预加载,您可以应用 DownSample,然后在您的 CachedImage 控件中使用转换。

    <forms:CachedImage
        x:Name="Blured"
        Aspect="Fill"
        CacheType="All"
        HorizontalOptions="Fill"
        Opacity="0.3"
        Source="YOUR_SOURCE_URI"
        VerticalOptions="Fill">
            <forms:CachedImage.Transformations>
                <fftransformations:BlurredTransformation Radius="30"/>
            </forms:CachedImage.Transformations>
     </forms:CachedImage>
    

    【讨论】:

      猜你喜欢
      • 2018-06-15
      • 2011-04-08
      • 1970-01-01
      • 2022-01-27
      • 1970-01-01
      • 2011-01-01
      • 2019-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多