实现应用Matrix旋转图像
来源:互联网 发布:阿里云ssh登录 编辑:程序博客网 时间:2024/06/07 16:16
1、布局文件
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/frameLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > </FrameLayout>
2、MainActivity
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FrameLayout ll = (FrameLayout)findViewById(R.id.frameLayout1); ll.addView(new MyView(this)); } public class MyView extends View{public MyView(Context context) {super(context);}@Overrideprotected void onDraw(Canvas canvas) {Paint paint = new Paint();//定义一个画笔Bitmap bitmap_gb = BitmapFactory.decodeResource(MainActivity.this.getResources(), R.drawable.background);canvas.drawBitmap(bitmap_gb, 0, 0,paint);//绘制背景图像Bitmap bitmap_rabbit = BitmapFactory.decodeResource(MainActivity.this.getResources(),R.drawable.rabbit);canvas.drawBitmap(bitmap_rabbit, 0, 0, paint);//绘制原图//应用setRotate(float degrees)方法旋转图像Matrix matrix = new Matrix();matrix.setRotate(30);//以(0,0)点为轴心旋转30°canvas.drawBitmap(bitmap_rabbit, matrix, paint);//绘制图像并应用matrix的变换//应用setRotate(float degrees,float px,float py)方法旋转图像Matrix m = new Matrix();m.setRotate(90, 87, 87);//以(87,87)点为轴心旋转90°canvas.drawBitmap(bitmap_rabbit, m, paint);//绘制图像并应用matrix的变换} } }
0 0
- 实现应用Matrix旋转图像
- 实现应用Matrix缩放图像
- android旋转图像Matrix
- android.graphics.Camera实现图像的旋转、缩放,配合Matrix...
- [Android]android.graphics.Camera实现图像的旋转、缩放,配合Matrix实现图像的倾斜
- android.graphics.Camera实现图像的旋转、缩放,配合Matrix实现图像的倾斜
- android.graphics.Camera实现图像的旋转、缩放,配合Matrix实现图像的倾斜
- [Android]android.graphics.Camera实现图像的旋转、缩放,配合Matrix实现图像的倾斜
- j2me实现图像旋转
- opencv实现图像旋转
- opencv实现图像旋转
- Opencv实现图像旋转
- OpenCV实现图像旋转
- opencv实现图像旋转
- opencv实现图像旋转
- 图像旋转的实现
- opencv实现图像旋转
- matlab实现图像旋转
- CodeForces 616B Dinner with Emma
- 实现tableView和collectionView的相互关联方法
- <LeetCode OJ> 141 / 142 Linked List Cycle(I / II)
- 行为型模式-状态模式state
- BeanUtils操作Bean的属性
- 实现应用Matrix旋转图像
- ElasticSearch path.home is not configured报错解决
- Qt程序界面美化一-- stylesheet
- Block和typedef
- vmstat
- 行为型模式-策略模式strategy
- 内存分配器一
- jquery对象不用new原因
- Android AppWidget开发