首页 > 其他 > 详细

12 Bitmap缩放

时间:2016-04-13 18:30:31      阅读:290      评论:0      收藏:0      [点我收藏+]
技术分享
 1 public  Bitmap zoomImage(Bitmap bgimage, double newWidth,
 2                                    double newHeight) {
 3         // 获取这个图片的宽和高
 4         float width = bgimage.getWidth();
 5         float height = bgimage.getHeight();
 6         // 创建操作图片用的matrix对象
 7         Matrix matrix = new Matrix();
 8         // 计算宽高缩放率
 9         float scaleWidth = ((float) newWidth) / width;
10         float scaleHeight = ((float) newHeight) / height;
11         // 缩放图片动作
12         matrix.postScale(scaleWidth, scaleHeight);
13         Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width,
14             (int) height, matrix, true);
15         return bitmap;
16     }
Bitmap缩放

 

12 Bitmap缩放

原文:http://www.cnblogs.com/YyuTtian/p/5387961.html

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