/**
* 将本地图片转换为位图
*
* @param pathName 图片本地路径名,如"/mnt/sdcart/a.jpg"
* @param rate 大小比率,如rate=10,则生成位图的width,hight为原图的十分之一
* @return 位图实例
* @throws FileNotFoundException
*/
public static Bitmap getBitmapByPath(String pathName, int rate) throws FileNotFoundException {
//读取文件到输入流
FileInputStream fis = new FileInputStream(pathName);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
options.inSampleSize = rate;
//使用位图工厂类将包含图片信息的输入流转换成位图
return BitmapFactory.decodeStream(fis, null, options);
}
android:本地图片转换为位图
最新推荐文章于 2021-05-29 05:57:38 发布