首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android:当地图片转换为位图

2012-07-20 
android:本地图片转换为位图/*** 将本地图片转换为位图** @param pathName 图片本地路径名,如/mnt/sdcart

android:本地图片转换为位图

    /**     * 将本地图片转换为位图     *      * @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);    }

热点排行