0

I'm using a GestureImageView to display a map with a custom layer for the selected theme. Depending on the theme I'm loading a LayerDrawable in the GestureImageView.

The way I use it, the Bitmaps are killing my memory and will throw a OutOfMemoryException. I would like to use Glide to load these bitmaps, but I can't figure out how to use a LayerDrawable with Glide.

EDIT: My original code without Glide:

private void loadImageFromStorage(String path, String name)
{

  try {

        File f=new File(path, name);

       BitmapFactory.Options options=new BitmapFactory.Options();
        options.inPreferredConfig = Bitmap.Config.RGB_565;
        options.inSampleSize=2;
    //    options.inJustDecodeBounds = true;
        Bitmap b = BitmapFactory.decodeStream(new FileInputStream(f),null,options);

        BitmapFactory.Options options2=new BitmapFactory.Options();
        options2.inPreferredConfig = Bitmap.Config.RGB_565;

        Drawable laag = new BitmapDrawable(b);
        Bitmap back = BitmapFactory.decodeResource(getResources(), R.drawable.bgverkenning, options2);

        Drawable bg = new BitmapDrawable(back);
        Drawable [] lagen = {bg,laag};
        LayerDrawable ld = new LayerDrawable(lagen);

       map.setImageDrawable(ld);

 }
    catch (FileNotFoundException e)
   {
        e.printStackTrace();
    }

}

And with Glide I only used some basic code like:

   Glide.with(this).load(ld).into(map);

But you have to use some kind of model since Glide doesn't understand the LayerDrawable.

TWiStErRob
  • 44,762
  • 26
  • 170
  • 254
Stefan
  • 2,098
  • 2
  • 18
  • 29

0 Answers0