Android图像处理(一) 简单的特效 平移 缩放 等
来源:互联网 发布:dota2周边淘宝店 编辑:程序博客网 时间:2024/05/17 22:57
- 相关文章
- 关键词
- 简单特效实现
- 效果图
- 代码下载
相关文章
1.Android图像图像处理(一) 简单的特效 平移 缩放 等
关键词
- BitMap 位图
- BitMapFactory 位图工厂
- Paint 画笔
- Canvas 画板
简单特效实现
package cn.zsp.bitmapdemo;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Matrix;import android.graphics.Paint;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.ImageView;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView imageView= (ImageView) findViewById(R.id.iv); ImageView imageViewCopy= (ImageView) findViewById(R.id.ivCopy); //通过bitmap工厂得到bitmap 原图 Bitmap bitMap= BitmapFactory.decodeResource(getResources(),R.drawable.a); imageView.setImageBitmap(bitMap); //创建bitmap副本 白纸 Bitmap alterBitMap=Bitmap.createBitmap(bitMap.getWidth(),bitMap.getHeight(),bitMap.getConfig()); //创建画笔 Paint paint=new Paint(); //画笔颜色 paint.setColor(Color.BLACK); //创建画板 铺上白纸 Canvas canvas=new Canvas(alterBitMap); //canvas.drawColor(); //画板颜色 //特效 Matrix matrix=new Matrix();// //旋转// matrix.setRotate(45);//围绕(0,0)点旋转多少度// matrix.setRotate(45,1,1);//围绕指定点旋转多少度// //缩放// matrix.setScale(2,2);//x,y 缩放比例// matrix.setScale(0.5f,0.5f,1,1);//围绕指定 //平移 // matrix.setTranslate(200,0);//平移后的坐标 //倒影// // (x轴不变y轴变负)// matrix.setScale(1,-1);// //向上平移 (两种效果第二个需要用post)// matrix.postTranslate(0,alterBitMap.getHeight()); //镜面 matrix.setScale(-1,1);//y轴不变 x轴变负 matrix.postTranslate(alterBitMap.getWidth(),0);//向右平移 //在白纸上绘制原图内容 canvas.drawBitmap(bitMap,matrix,paint); //imageviewCopy 设置图片 imageViewCopy.setImageBitmap(alterBitMap); }}
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="cn.zsp.bitmapdemo.MainActivity" android:orientation="vertical" android:gravity="center"><ImageView android:id="@+id/iv" android:layout_width="match_parent" android:layout_height="wrap_content"/><ImageView android:id="@+id/ivCopy" android:layout_width="wrap_content" android:layout_height="wrap_content"/></LinearLayout>
效果图
代码下载
链接:http://pan.baidu.com/s/1pLaP3HD 密码:ap1s
0 0
- Android图像处理(一) 简单的特效 平移 缩放 等
- Android-实现图片的简单特效(平移、缩放、旋转、镜面、倒影)
- Android游戏4-27 实现图像特效-旋转 缩放 平移
- 【OpenCV3图像处理】图像简单几何变换:旋转、平移、缩放
- 图像的平移,缩放..
- 图像的平移和缩放
- Android学习笔记11:图像的平移、旋转及缩放
- Android学习笔记11:图像的平移、旋转及缩放
- Android bitmap的拷贝以及平移旋转缩放等效果
- Android --小功能 Android中几种图像特效处理 (一)
- Android --- 图片的特效处理(缩放,圆角,倒影)
- Android图形处理基本api(缩放,旋转,平移)
- matlab实现图像的平移、旋转、缩放
- matlab实现图像的平移、旋转、缩放
- Matlab 实现图像的平移,旋转,缩放
- chapter14_1图像的缩放与平移
- 图像处理之图像基本变化(平移、缩放、旋转)(Octave实现)
- 【Android开发】图形图像处理技术-旋转、缩放、倾斜和平移图像
- Formatter
- Android从按下开机键到启动发生了什么
- 104. Maximum Depth of Binary Tree
- 走马观花: Linux 系统调用 open 七日游(六)
- ViewPager+RadioGroup+Fragment实现选项卡
- Android图像处理(一) 简单的特效 平移 缩放 等
- 【Leetcode】Repeated DNA Sequences
- 在64位的系统中安装32位的库
- RelativeLayout佈局介紹
- 【Leetcode】ZigZag Conversion
- android DHCP流程
- 走马观花: Linux 系统调用 open 七日游(七)
- 基于案例贯通Spark Streaming流计算框架的运行源码
- 如何解决PowerPoint课件中的菜单问题