实现图片缩放
2016-02-10 23:24
281 查看
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; }
相关文章推荐
- JPA下打印执行的SQL
- hdu 3367 Pseudoforest 最大权值和伪森林
- UVa11324 The Largest Clique(强连通分量+缩点+记忆化搜索)
- js 中的流程控制—while和do while
- haproxy日志配置
- 242. Valid Anagram
- 创建haproxy启动脚本
- 算法导论例程——二叉搜索树
- haproxy 配置文件说明
- haproxy ssl 配置方式
- bzoj1430: 小猴打架
- How do I install uudecode?
- HTTP与HTTPS握手的那些事
- 100. Same Tree
- 283. Move Zeroes
- Android开发笔记(六十一)文件下载与上传
- bzoj1412(最小割)
- mongodb主从模式部署
- 226. Invert Binary Tree
- mongodb用户权限配置