Android 图片旋转(使用Matrix.setRotate方法)
imageView2 = (ImageView) findViewById(R.id.img2); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
//创建一个与bitmap一样大小的bitmap2
Bitmap bitmap2 = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
Canvas canvas = new Canvas(bitmap2);
//主要以这个对象调用旋转方法
Matrix matrix = new Matrix();
//以图片中心作为旋转中心,旋转180°
matrix.setRotate(180, bitmap2.getWidth() / 2, bitmap2.getHeight() / 2);
Paint paint = new Paint();
//设置抗锯齿,防止过多的失真
paint.setAntiAlias(true);
canvas.drawBitmap(bitmap, matrix, paint);
//将旋转后的图片设置到界面上
imageView2.setImageBitmap(bitmap2);
Android 图片旋转(使用Matrix.setRotate方法)的更多相关文章
- Android图片处理(Matrix,ColorMatrix) - 转载
Android图片处理(Matrix,ColorMatrix) 转载自:http://www.cnblogs.com/leon19870907/articles/1978065.html 在编程中有时 ...
- Android图片旋转,缩放,位移,倾斜,对称完整示例(一)——imageView.setImageMatrix(matrix)和Matrix
MainActivity如下: import android.os.Bundle; import android.view.MotionEvent; import android.view.View; ...
- Android图片旋转,缩放,位移,倾斜,对称完整演示样例(一)——imageView.setImageMatrix(matrix)和Matrix
MainActivity例如以下: import android.os.Bundle; import android.view.MotionEvent; import android.view.Vie ...
- android图片压缩的3种方法实例
android 图片压缩方法: 第一:质量压缩法: private Bitmap compressImage(Bitmap image) { ByteArrayOutputStream baos = ...
- Android图片处理(Matrix,ColorMatrix)
转发说明:原文链接http://www.cnblogs.com/leon19870907/articles/1978065.html 在编程中有时候需要对图片做特殊的处理,比如将图片做出黑白的,或者老 ...
- 我的Android进阶之旅------>Android图片处理(Matrix,ColorMatrix)
本文转载于:http://www.cnblogs.com/leon19870907/articles/1978065.html 在编程中有时候需要对图片做特殊的处理,比如将图片做出黑白的,或者老照片的 ...
- android 图片旋转 移动 放大缩小
图片的变化主要是matrix的变化,对matrix不懂的可以先了解下matrxi. public class FunnyView extends View { /* * 手指按下时可能是移动 也可能是 ...
- QT 实现图片旋转的两种方法
第一种方案 使用 QPixmap 的 transformed 函数来实现旋转,这个函数默认是以图片中心为旋转点,不能设置旋转的中心点,使用如下: QMatrix matrix; matrix.rota ...
- Android 图片旋转
拍照后的照片有时被系统旋转,纠正步骤如下: 1.先读取图片文件被旋转的角度: /** * 通过ExifInterface类读取图片文件的被旋转角度 * @param path : 图片文件的路径 * ...
随机推荐
- Ant 修改项目pom.xml文件应用
<?xml version="1.0" encoding="UTF-8"?> <project name="project" ...
- Swift静态属性
在介绍静态属性之前,我们先来看一个类的设计,有一个Account(银行账户)类,假设它有3个属性:amount(账户金额).interestRate(利率)和owner(账户名).在这3个属性中,am ...
- javascript笔记——jqGrid再次封装
xingrunzhao js插件再次封装 demo 'use strict'; /** * commerce grid框架 * 依赖jqgrid */ (function ($_self, jQuer ...
- c#跨窗体调用操作
我知道的常用的有三种,以前记录的笔记: 1.通过构造函数实现 在form1的load事件中new form2时 在构造函数里添加一个参数 此参数就是form1类型的参数,同时记得在form2里重写构 ...
- python 函数应用
#函数的参数就是个变量 #定义函数的时候,使用关键字参数,可以指定默认值 def hello(name='reboot',age=1): return 'hello %s,your age is %s ...
- 鼠标滑过提示title
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1. ...
- jquery返回顶部特效
<style> p#back-to-top{position:fixed; bottom:100px;right:10px; display: none; } p#back-to-top ...
- jQuery scroll(滚动)延迟加载
延迟加载 $(window).scroll(function(){ var scrollHeight = $(document).height(); //文档高度 var scrollTop = $( ...
- linux计划任务运行php文件的方法分享
在linux下,借助crontab,设置计划任务每天6点10分执行filename.php文件,写入一行时间到log日志中. 创建计划任务的脚本: dos2unix /path/to/filename ...
- Nginx Location配置总结及基础最佳实践
参考来源: http://blog.zol.com.cn/1067/article_1066186.html,http://flandycheng.blog.51cto.com/855176/2801 ...