图片文件转为Bitmap对象
String filePath="c:/01.jpg";

Bitmap bitmap=BitmapFactory.decodeFile(filePath);

如果图片过大,可能导致Bitmap对象装不下图片
解决办法:
String filePath="c:/01.jpg";
Bitmap bitmap=BitmapFactory.decodeFile(filePath,getBitmapOption(2)); //将图片的长和宽缩小味原来的1/2


private Options getBitmapOption(int inSampleSize){
        System.gc();
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPurgeable = true;
        options.inSampleSize = inSampleSize;
        return options;
}

相关文章:

  • 2021-07-02
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-26
  • 2021-06-13
  • 2021-09-29
相关资源
相似解决方案