BitmapUtil.java 文件源码

java
阅读 45 收藏 0 点赞 0 评论 0

项目:GCSApp 作者:
/**
 * @description:解析Bitmap的公用方法.注意各个方法的参数必须要有options
 * @author:hui-ye
 * @param path
 * @param data
 * @param context
 * @param uri
 * @param options
 * @return:
 */

public static Bitmap decode(String path, byte[] data, Context context, Uri uri,
                            Options options) throws Exception {
    Bitmap bitmap = null;
    if (path != null) {
        bitmap = BitmapFactory.decodeFile(path, options);
    } else if (data != null) {
        BitmapFactory.decodeByteArray(data, 0, data.length, options);
    } else if (uri != null) {
        // uri不为空的时候context也不要为空.:ContentResolver;Uri内容解析器
        ContentResolver resolver = context.getContentResolver();
        InputStream is;
        is = resolver.openInputStream(uri);
        bitmap = BitmapFactory.decodeStream(is, null, options);
    }
    System.gc();
    return bitmap;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号