图片压缩
来源:互联网 发布:伤感网络歌曲下载 编辑:程序博客网 时间:2024/06/16 10:36
这是自定义的封装类,从网络请求出来数据以后调用下面的自定义方法就可以了
public class ImageResizerUtils { public static Bitmap ImageResizerNotWork(URL url, InputStream is, int reqWidth, int reqHeight) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(is, null, options); int width = options.outWidth; int height = options.outHeight; int SampleSize = 1; if (width > reqWidth || height > reqHeight) { int halfwidth = width / 2; int halfheight = height / 2; while ((halfwidth / SampleSize) >= reqWidth && (halfheight / SampleSize) >= reqHeight) { SampleSize *= 2; } } options.inSampleSize =SampleSize; options.inJustDecodeBounds=false; is.close(); InputStream inputStream = url.openStream(); Bitmap bitmap = BitmapFactory.decodeStream(inputStream, null, options); return bitmap; } catch (IOException e) { e.printStackTrace(); } return null; }}
阅读全文
0 0
- 图片压缩。大小压缩
- 图片压缩按比例压缩
- 压缩图片
- 压缩图片
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 压缩图片
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 压缩图片
- 图片压缩
- mysql时间字符串和时间戳转换
- ListView源码分析
- 浅谈HTTP中Get与Post的区别
- 深度学习助力实现智能行为分析和事件识别
- 《Flask Web开发》学习笔记之bug--(9)【jinja2.exceptions.TemplateSyntaxError: unexpected '%'】
- 图片压缩
- 冒泡排序 java实现
- node.js
- 写个接口的实现类,在方法的前面加了@Override居然报错
- JavaWeb程序运行缓慢原因分析之一
- java中的sleep()和wait()的区别
- 三天入门Python---文件操作(第三天)
- 使用build.grade文件配置相关参数与多渠道打包
- es6学习笔记1