获取资源文件:
public
static Bitmap readBitMap(Context context, int resId){
BitmapFactory.Options opt
= new BitmapFactory.Options();
opt.inPreferredConfig
= Bitmap.Config.RGB_565;
opt.inPurgeable
= true;
opt.inInputShareable
= true;
//获取资源图片
InputStream is = context.getResources().openRawResource(resId);
return BitmapFactory.decodeStream(is,null,opt);
}
回收bitmap
public static void recycle(Bitmap bmp){

if(bmp!=null&&!bmp.isRecycled() )
{
bmp.recycle();
//回收图片所占的内存
System.gc(); //提醒系统及时回收
}
}

相关文章:

  • 2021-11-25
  • 2021-10-14
  • 2021-06-12
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
猜你喜欢
  • 2021-07-22
  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2021-07-25
相关资源
相似解决方案