fresco icon indicating copy to clipboard operation
fresco copied to clipboard

How can i known the image path cached on disk?

Open hyvenzhu opened this issue 11 years ago • 2 comments

as the question title,when user see the image,he wont to save the image or share with anyone,how can i do with fresco?

hyvenzhu avatar May 06 '15 14:05 hyvenzhu

I have made this using pipeline I get the image save it to sd card then share it, it would be better if we can get the URI directly without saving it again. This is the code :

ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).build();

    DataSource<CloseableReference<CloseableImage>> dataSource =
            mImagePipeline.fetchDecodedImage(imageRequest, this);

    try {
        Bitmap bitmap;
        CloseableReference<CloseableImage> imageReference = dataSource.getResult();
        if (imageReference != null) {
            try {
                bitmap = ((CloseableBitmap) imageReference.get()).getUnderlyingBitmap();

                    file = FilesUtils.saveShareBitmap(bitmap, Consts.APP_ALBUM, "image" + currentItem + ".jpg");

                          Uri imageUri = Uri.fromFile(file);

            } finally {
                CloseableReference.closeSafely(imageReference);
            }
        }
    } finally {
        dataSource.close();
    }

mohammedhammouri avatar May 08 '15 08:05 mohammedhammouri

You can simply use the image pipeline to retrieve the encoded image out of cache. Then just save it to a file.

tyronen avatar May 08 '15 15:05 tyronen