Interceptors.java 文件源码

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

项目:HDImageView 作者:
public static BitmapRegionDecoder fixJPEGDecoder(File file, IOException e) throws IOException {

        if (file == null || !file.exists()){
            throw e;
        }

        Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(),new BitmapFactory.Options());
        if (bitmap == null) {
            if (BuildConfig.DEBUG) {
                Log.d(TAG, "加载缓存失败:" + file.getAbsolutePath());
            }
            throw e;
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 85, baos);
        BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(baos.toByteArray(),0,baos.size(),false);
        bitmap.recycle();
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "fixJPEGDecoder: 从此处修复Bitmap");
        }
        return decoder;
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号