Matrix bitmap 怎样使用Matrix对bitmap的旋转与镜像水平垂直翻转

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Matrix bitmap 怎样使用Matrix对bitmap的旋转与镜像水平垂直翻转

  2021-03-18 我要评论
想了解怎样使用Matrix对bitmap的旋转与镜像水平垂直翻转的相关内容吗,在本文为您仔细讲解Matrix bitmap的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Matrix,bitmap,下面大家一起来学习吧。
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;
}

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们