Bitmap和File相互转换
作者:互联网
图片文件转为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;
}
标签:inSampleSize,Options,转换,filePath,Bitmap,BitmapFactory,File,options 来源: https://www.cnblogs.com/xiaoyao-blog/p/13961937.html