码迷,mamicode.com
首页 > 移动开发 > 详细

Android Bitmap 缩放 旋转 水印 裁剪操作

时间:2014-10-31 22:01:13      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   http   os   sp   strong   on   2014   

在android当中,Bitmap代表一个图片,里面封装了图片的信息。

一,将图片进行缩放操作。

(1)获得Bitmap对象 

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a);  

(2)创建Matrix

Matrix matrix = new Matrix();  

matrix.postScale(0.5f, 0.5f);  //缩放50%

(3)创建新的Bitmap

Bitmap dstbmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);

上面参数的解释一下 public static Bitmap createBitmap (Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)

source 这个是需要缩放的原始图片 ,Matrix是矩阵对象用来指定缩放比例(也可以是旋转,扩大等其它操作都用该对象), filter不知道干啥的。

x,y  width,heigjt 这4个参数是指定缩放原始图片的什么位置 , 比如有一张 300X200(width*height) 的图片, 那么传入 100 ,100, 200, 100 的意思就是说从

下图灰色部分缩放,从原图X轴100像素 往右200个像素  从Y轴100像素开始 向下100像素。

bubuko.com,布布扣

 

 

 

 

 

 

 

Android Bitmap 缩放 旋转 水印 裁剪操作

标签:android   style   blog   http   os   sp   strong   on   2014   

原文地址:http://www.cnblogs.com/daxin/p/4066028.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!