android缩放图片
来源:互联网 发布:linux保存退出命令步骤 编辑:程序博客网 时间:2024/05/29 15:05
public static Bitmap scaleImg(Bitmap bm, int newWidth, int newHeight) {
// 获得图片的宽高
int width = bm.getWidth();
int height = bm.getHeight();
// 设置想要的大小
int newWidth1 = newWidth;
int newHeight1 = newHeight;
// 计算缩放比例
float scaleWidth = ((float) newWidth1) / width;
float scaleHeight = ((float) newHeight1) / height;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
// 得到新的图片
Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,
true);
if(width != newWidth && height != newHeight){
freeBitmap(bm);
}
return newbm;
}
// 获得图片的宽高
int width = bm.getWidth();
int height = bm.getHeight();
// 设置想要的大小
int newWidth1 = newWidth;
int newHeight1 = newHeight;
// 计算缩放比例
float scaleWidth = ((float) newWidth1) / width;
float scaleHeight = ((float) newHeight1) / height;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
// 得到新的图片
Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,
true);
if(width != newWidth && height != newHeight){
freeBitmap(bm);
}
return newbm;
}
- Android 图片缩放
- Android 图片缩放-Matrix
- android图片的缩放
- android图片的缩放
- Android 图片缩放-Matrix
- android图片的缩放 .
- android 两点缩放图片
- android ImageView图片缩放
- android 图片缩放
- android 图片缩放
- android 两点缩放图片
- Android图片缩放方法
- android 图片缩放
- Android 缩放图片
- android缩放图片
- Android 图片缩放
- android图片手势缩放
- android ImageView图片缩放
- 设计模式之抽象工厂模式
- 根据经纬度计算该位置点与附近某一经纬度位置点的位置偏移角
- ListView的Adapter使用 之 初学ArrayAdapter<String>
- System.IndexOutOfRangeException: 无法找到表 0解决办法
- 数据安全意识
- android缩放图片
- 在ubuntu下如何验证文件的MD5码
- 从myspace数据库看分布式系统数据结构变迁
- 解决vs2005在IE8下不能调试问题
- 动态修改listview,spinner控件字体大小的解决办法
- 全面兼容IE6/IE7/IE8/FF的CSS HACK写法
- iPhone开发基础教程笔记(十一)--第十一章 基本数据持久性(属性列表、归档对象、SQLite3)
- Zookeeper开源客户端框架Curator简介
- UIAlertView+UIActivityIndicatorView