毕加索缓存返回转换后的图像而不是原始图像



我正在使用毕加索作为我的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);

在此之后,两个图像视图将显示图像,并对其应用转换

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

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);
}

最新更新