首页 > 其他 > 详细

实现图片缩放

时间:2016-02-11 00:32:23      阅读:240      评论:0      收藏:0      [点我收藏+]
private Bitmap resizeImage(Bitmap originalBitmap, int newWidth, int newHeight){
int width = originalBitmap.getWidth();
int height = originalBitmap.getHeight();
//定义欲转换成的宽、高
// int newWidth = 200;
// int newHeight = 200;
//计算宽、高缩放率
float scanleWidth = (float)newWidth/width;
float scanleHeight = (float)newHeight/height;
//创建操作图片用的matrix对象 Matrix
Matrix matrix = new Matrix();
// 缩放图片动作
matrix.postScale(scanleWidth,scanleHeight); //两个参数为宽度和高度的缩放
//旋转图片 动作
//matrix.postRotate(45);
// 创建新的图片Bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(originalBitmap,0,0,width,height,matrix,true);
return resizedBitmap;
}

实现图片缩放

原文:http://www.cnblogs.com/to-creat/p/5186206.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!