android中Bitmap图像处理 修改图片大小以及保存时的文件大小
来源:互联网 发布:应用市场软件 编辑:程序博客网 时间:2024/05/17 07:48
- Options options1 = new Options();
- options1.inJustDecodeBounds = true;
- BitmapFactory.decodeFile(filePath, options1);
- options1.inSampleSize = RegisterTool.calculateInSampleSize(options1, 110, 160); //110,160:转换后的宽和高,具体值会有些出入
- options1.inJustDecodeBounds = false;
- Bitmap bitmap = BitmapFactory.decodeFile(filePath, options1); //filePath:文件路径
- public static int calculateInSampleSize(BitmapFactory.Options options,
- int reqWidth, int reqHeight) {
- final int height = options.outHeight;
- final int width = options.outWidth;
- int inSampleSize = 1;
- if (height > reqHeight || width > reqWidth) {
- final int heightRatio = Math.round((float) height
- / (float) reqHeight);
- final int widthRatio = Math.round((float) width / (float) reqWidth);
- inSampleSize = heightRatio < widthRatio ? widthRatio : heightRatio;
- }
- return inSampleSize;
- }
- //压缩图片并将Bitmap保存到本地
- FileOutputStream out = new FileOutputStream(new File(filePath));
- saveBitmap.compress(Bitmap.CompressFormat.JPEG, 60, out); //60代表压缩40%
0 0
- android中Bitmap图像处理 修改图片大小以及保存时的文件大小
- android中Bitmap图像处理 修改图片大小以及保存时的文件大小
- Android的图像处理类Bitmap
- Android的图像处理类Bitmap
- android bitmap文件修改保存
- android BitMap 设置图片大小
- Android中bitmap图像的缩放
- android图像处理之Bitmap
- Android图像处理之Bitmap 生成图片 解析 保存文件 获取 问题
- android如何高效的在native处理bitmap图像
- Android中常用的bitmap处理方法
- Android Bitmap图像优化(中)
- Android中缓存Bitmap图像
- android 修改RadioButton的drawTop图片大小
- Android图像处理之Bitmap类
- Android图像处理之Bitmap类
- Android图像处理之Bitmap类
- Android图像处理之Bitmap类
- java中最常用的jar包的用途说明
- Ubuntu 12.04下安装 Tomcat
- 安卓相对布局的一个小问题记录
- onvif 客户端发现
- 设计模式——适配器模式
- android中Bitmap图像处理 修改图片大小以及保存时的文件大小
- Note On <Programming Entity Framework 2nd Edition> -04
- android解决工具类中没有context中的问题
- RabbitMQ使用实践
- Leetcode --Sudoku Solver
- oracle官方文档之V$SESSION
- Linux如何查看so中函数名
- CentOS 7中没有ifconfig命令,而且不能发现eth0
- 获取罗辑思维每天的微信语音(python)