1

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

我在后台执行此代码:从 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?

4

1 回答 1

0

Transformations 不会影响 Image 的缓存版本,它们只会改变 imageSource 的呈现方式。

在您的图像预加载情况下,您可以应用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>
于 2017-06-25T22:52:54.703 回答