对bitmap进行旋转和镜像操作

来源:互联网 发布:海蝶手机网址导航源码 编辑:程序博客网 时间:2024/04/27 12:36
Bitmap convert(Bitmap a, int width, int height)
{
int w = a.getWidth();
int h = a.getHeight();
Bitmap newb = Bitmap.createBitmap(ww, wh, Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图
Canvas cv = new Canvas(newb);
Matrix m = new Matrix();
m.postScale(1, -1);   //镜像垂直翻转
m.postScale(-1, 1);   //镜像水平翻转
m.postRotate(-90);  //旋转-90度
Bitmap new2 = Bitmap.createBitmap(a, 0, 0, w, h, m, true);
cv.drawBitmap(new2, new Rect(0, 0, new2.getWidth(), new2.getHeight()),new Rect(0, 0, ww, wh), null);
return newb;
}
0 0
原创粉丝点击