码迷,mamicode.com
首页 > 其他好文 > 详细

12 Bitmap缩放

时间:2016-04-13 18:33:41      阅读:118      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!