【问题标题】:Picasso cache returning transformed image instead of original毕加索缓存返回转换后的图像而不是原始图像
【发布时间】:2016-01-17 20:13:46
【问题描述】:

我将毕加索用于我的 Android 应用程序。使用毕加索转换我渲染了在我的应用程序的某些部分转换的图像,但是当我尝试在另一部分渲染图像时,我也得到了转换后的图像。我怎样才能让原始图像在不转换的情况下显示它?

这是一个代码示例。

String imageUrl = "http://path/image.png";

CustomTransformation *trans= new CustomTransformation();
Picasso.with(this).load(imageUrl).transform(trans).into(myImageView1);
Picasso.with(this).load(imageUrl).into(myImageView2);

在这之后,两个图像视图都显示了应用了变换的图像

【问题讨论】:

  • 请提供一些代码!
  • @PatrickMA 我添加了一些代码,现在更清晰了

标签: android picasso image-caching


【解决方案1】:

可能您没有设置转换键,因此缓存机制看不到差异。 示例:

private Transformation blur = new Transformation() {
    @Override
    public Bitmap transform(Bitmap source) {
        Bitmap blurred = BitmapUtils.createBlurredBitmap(source);
        source.recycle();
        return blurred;
    }

    @Override
    public String key() {
        return "blurred";   //this will be added to the key that Picasso uses for caching
    }
};
//key: <uri>\nblurred
void loadAndBlur(Uri uri, ImageView mPhoto) {
        picasso.load(uri).transform(blur).into(mPhoto);
}
//key: <uri>
void load(Uri uri, ImageView mPhoto) {
        picasso.load(uri).into(mPhoto);
}

【讨论】:

    猜你喜欢
    • 2014-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-07
    • 2019-09-14
    • 2021-02-21
    • 2016-08-08
    • 2016-06-18
    相关资源
    最近更新 更多