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

如何使用Matrix对bitmap的旋转与镜像水平垂直翻转_android开发_ThinkSAAS
如何使用Matrix对bitmap的旋转与镜像水平垂直翻转
如何使用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);}
PHP开发框架
开发工具/编程工具
服务器环境
ThinkSAAS商业授权:
ThinkSAAS为用户提供有偿个性定制开发服务
ThinkSAAS将为商业授权用户提供二次开发指导和技术支持
让ThinkSAAS更好,把建议拿来。
开发客服微信相关热词搜索:问题小结(24)--获取已有图片的镜像图片
方法如下,通过Matrix对图片进行处理。
public Bitmap convertBmp(Bitmap bmp){&
&&& int w = bmp.getWidth();&
&&& int h = bmp.getHeight();&
&&& Bitmap convertBmp = Bitmap.createBitmap(w, h, Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图&&
&&& Canvas cv = new Canvas(convertBmp);&
&&& Matrix matrix = new Matrix();&
&&& matrix.postScale(1, -1); //镜像垂直翻转&&
//& matrix.postScale(-1, 1); //镜像水平翻转&&
//& matrix.postRotate(-90); //旋转-90度&&
&&& Bitmap newBmp = Bitmap.createBitmap(bmp, 0, 0, w, h, matrix, true);&
&&& cv.drawBitmap(newBmp, new Rect(0, 0,newBmp.getWidth(), newBmp.getHeight()),new Rect(0, 0, w, h), null);&
&&& return convertB&
public Bitmap convertBmp(Bitmap bmp){
&int w = bmp.getWidth();
&int h = bmp.getHeight();
&Bitmap convertBmp = Bitmap.createBitmap(w, h, Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图
&Canvas cv = new Canvas(convertBmp);
&Matrix matrix = new Matrix();
&matrix.postScale(1, -1); //镜像垂直翻转
//&matrix.postScale(-1, 1); //镜像水平翻转
//&matrix.postRotate(-90); //旋转-90度
&Bitmap newBmp = Bitmap.createBitmap(bmp, 0, 0, w, h, matrix, true);
&cv.drawBitmap(newBmp, new Rect(0, 0,newBmp.getWidth(), newBmp.getHeight()),new Rect(0, 0, w, h), null);
&return convertB
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'6127人阅读
Android(73)
工作知识(18)
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);
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:643483次
积分:6843
积分:6843
排名:第2589名
原创:90篇
转载:100篇
评论:119条
(1)(2)(2)(2)(2)(2)(4)(4)(2)(8)(2)(2)(4)(1)(14)(7)(1)(3)(7)(9)(5)(6)(8)(32)(12)(10)(5)(34)Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。
本篇文章是对使用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);}
Copyright &
All Rights Reserved &&&&&&

我要回帖

更多关于 bitmatrix bitmap 的文章

 

随机推荐