android中Bitmap图像处理 修改图片大小以及保存时的文件大小
来源:互联网 发布:ben simmons数据 编辑:程序博客网 时间:2024/04/29 23:40
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%
1 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类
- ASP.NET MVC 5-开始MVC5之旅
- 在ogre里面显示二维图片
- nyoj_16_矩形嵌套
- 黑马程序员-集合框架的Set集合
- 最小生成树 模板
- android中Bitmap图像处理 修改图片大小以及保存时的文件大小
- 岁月静好
- 10个让人心情变好的颜色【附RGB值以及html值】
- hdu1254推箱子(BFS)
- Spiral Matrix
- Ubuntu查找替换命令
- [ext4]09 磁盘布局 - superblock备份机制
- Synchronized和Static Synchronized区别
- Mac环境下Android APK包反编译详解