BitmapUtil.java 文件源码

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

项目:AppCommonFrame 作者:
/**
 * 从系统的asset中读取一张图片 . <br>
 * @author liulongzhenhai 2012-8-1 下午5:21:12 <br>
 * @param context 上下文
 * @param fileName 文件相对路劲
 * @param density Options.inDensity的设置,在一些情况下,需要制定.否则,会变形
 * @return 返回图片
 */
public static Bitmap getImageFromAssetFile(final Context context, final String fileName, final int density) {
    if (TextUtils.isEmpty(fileName)) {
        return null;
    }
    Bitmap image = null;
    try {
        final AssetManager am = context.getAssets();
        final InputStream is = am.open(fileName);
        final Options o = new Options();
        o.inDensity = density;
        image = BitmapFactory.decodeStream(is, null, o);
        is.close();
    } catch (final Exception e) {
    }
    return image;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号