图像处理详解之图像旋转
来源:互联网 发布:网络订餐 南京食药监 编辑:程序博客网 时间:2024/06/16 15:02
图像旋转的基本思想是通过Matrix类的setRotate方法设置旋转的角度,然后使用Bitmap.createBitmap方法创建一个已经旋转了的图像。除此之外,还可以使用Canvas.setMatrix方法设置,并直接使用drawBitmap绘制。
下面来实现一个旋转动画:
实现方法如下:
public class MainActivity extends Activity{public static int alpha=100;private View myView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new MyView(this)); }private class MyView extends View{//十字扳手图像private Bitmap bitmap1;//小球图像private Bitmap bitmap2;//十字扳手当前角度private int digree1 = 0;//小球当前角度private int digree2 = 360;public MyView(Context context){super(context);setBackgroundColor(color.white);InputStream is = getResources().openRawResource(R.drawable.cross);bitmap1 = BitmapFactory.decodeStream(is);is = getResources().openRawResource(R.drawable.ball);bitmap2 = BitmapFactory.decodeStream(is);}@Overrideprotected void onDraw(Canvas canvas){Matrix matrix = new Matrix();//讲旋转角度控制在0-360if (digree1 > 360)digree1 = 0;if(digree2 < 0)digree2 = 360;//设置旋转角度和旋转中心点matrix.setRotate(digree1++, 160, 240);canvas.setMatrix(matrix);//绘制图像canvas.drawBitmap(bitmap1, 88, 169, null);//设置旋转角度和旋转中心点matrix.setRotate(digree2--,160 , 240);canvas.setMatrix(matrix); //绘制图像canvas.drawBitmap(bitmap2, 35, 115, null);//在onDrow中调用invalidate方法,表示不断重绘,即实现动画效果invalidate();}}}
- 图像处理详解之图像旋转
- 图像处理之旋转图像
- 图像处理之图像快速旋转算法
- 图像处理 - 图像旋转
- 【VC图像处理】旋转图像
- 图像处理详解之图像透明度
- 图像处理之旋转实现笔记
- 图像处理详解之MaskFilter
- 【数字图像处理】六.MFC空间几何变换之图像平移、镜像、旋转、缩放详解
- CCF之图像旋转
- 图像处理(五)图像旋转
- 数字图像处理:6.旋转图像
- 图像处理16:图形旋转
- /LGC图形渲染/图像处理系列之旋转
- 图像处理之线性插值旋转算法(biline-interpolation rotate algorithm)
- 【数字图像处理之四】图像的放大缩小旋转
- Matlab图像几何变换之图像旋转
- 图像处理 之 图像保存
- Emacs快捷键
- DBMS_LOCK包的学习
- FPGA Verilog HDL 系列实例--------直流电机PWM控制
- 交通灯管理系统
- FPGA Verilog HDL 系列实例--------卡式电话计费器
- 图像处理详解之图像旋转
- 黑马程序员_java之多线程
- CLisp 24:宏的本质也是函数
- winedt7.0的使用及显示
- Bean Inheritance
- arduino on android 4.0
- .NET框架与COM:背景和历史,关系的发展
- poj 1579
- 直接插入排序。数组下标实现。