图片压缩
来源:互联网 发布:Tensorflow 字符识别 编辑:程序博客网 时间:2024/06/06 14:32
/** * 根据路径,二次采样并且压缩 * @param filePath 路径 * @param destWidth 压缩到的宽度 * @param destHeight 压缩到的高度 * @return */ public Bitmap convertToBitmap(String filePath, int destWidth, int destHeight) { //第一采样 BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(filePath, options); int outWidth = options.outWidth; int outHeight = options.outHeight; int sampleSize = 1; while ((outWidth / sampleSize > destWidth) || (outHeight / sampleSize > destHeight)) { sampleSize *= 2; } //第二次采样 options.inJustDecodeBounds = false; options.inSampleSize = sampleSize; options.inPreferredConfig = Bitmap.Config.RGB_565; return BitmapFactory.decodeFile(filePath, options); }
0 0
- 图片压缩。大小压缩
- 图片压缩按比例压缩
- 压缩图片
- 压缩图片
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 压缩图片
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 图片压缩
- 压缩图片
- 图片压缩
- Xcode常用的快捷键
- EasyUI 扩展自定义EasyUI校验规则 验证规则(常用的)
- Android打包失败Proguard returned with error code 1. See console
- 常用springboot注解
- RelativeLayout布局中linearlayout布局居中
- 图片压缩
- 造车牌的代码
- oracle ceil和floor函数
- 0421
- 装完jdk后配置环境变量时,不小心把path里的内容删了,怎么办?
- 南阳OJ 题目34 韩信点兵
- thymeleaf模板对没有结束符的HTML5标签解析出错的解决办法
- 《PCL点云库学习&VS2010(X64)》Part 33 循环中的多个点云ID处理技巧
- GDB十分钟教程