0

我正在使用 GestureImageView 显示带有所选主题的自定义图层的地图。根据我在 GestureImageView 中加载 LayerDrawable 的主题。

我使用它的方式是,位图正在扼杀我的记忆,并会抛出 OutOfMemoryException。我想使用 Glide 来加载这些位图,但我不知道如何将 LayerDrawable 与 Glide 一起使用。

编辑:我没有 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();
    }

}

在 Glide 中,我只使用了一些基本代码,例如:

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

但是你必须使用某种模型,因为 Glide 不理解 LayerDrawable。

4

0 回答 0