0

How to get filepath to cached bitmap ?

When loading from url like below, I'm able to get filePath to the cached image

var obj = Glide.With(this)
             .Load("url")
             .Submit()
             .Get();
if (obj is Java.IO.File file) 
{
    using var handler = new Handler(Looper.MainLooper);
    handler.Post(() =>
    {
       Glide.With(this)
            .Load(file)
            .SetDiskCacheStrategy(DiskCacheStrategy.All)
            .Downsample(DownsampleStrategy.CenterInside)
            .Listener(this)
            .Into(imageView);
    });
}
   

But how to get filepath for bitmap when loading a bitmap like below ?

Bitmap bitmap = //populate bitmap
var obj = Glide.With(this)
                .Load(bitmap)
                .Submit()
                .Get();
//obj is a Bitmap here
 using var handler = new Handler(Looper.MainLooper);
 handler.Post(() =>
 {
    Glide.With(this)
         .Load(obj)
         .SetDiskCacheStrategy(DiskCacheStrategy.All)
         .Downsample(DownsampleStrategy.CenterInside)
         .Listener(this)
         .Into(imageView);
 });
5
  • Do you want path to bitmap as ur are getting for the Url ? Commented Sep 10, 2024 at 5:43
  • @GauravBharadia Yes :) Commented Sep 10, 2024 at 6:39
  • There is no path to a bitmap, you have to save it to cache or storage to get file Commented Sep 10, 2024 at 6:52
  • @GauravBharadia But don't I save it by .SetDiskCacheStrategy(DiskCacheStrategy.All) ? Or how do I save it to cache? Commented Sep 10, 2024 at 7:01
  • It only applies to url image links as far as i know. Bitmap is on the RAM not in storage so first save it then you will get its path. Commented Sep 10, 2024 at 7:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.