android drawBitmapMesh
来源:互联网 发布:经期提前 知乎 编辑:程序博客网 时间:2024/05/16 03:36
package com.example.and6;import android.annotation.SuppressLint;import android.content.Context;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.graphics.Canvas;import android.util.AttributeSet;import android.widget.ImageView;public class MeshView extends ImageView{Bitmap bitmap;//分割成50*50个格int WIDTH=50;int HEIGHT=50;//依次存放每一个点的 x y坐标float[]origs=new float[ ( (WIDTH+1)*(HEIGHT+1) )*2];float[]verts=new float[origs.length];float k;boolean isStart=false;public MeshView(Context context) {super(context);init();}public MeshView(Context context, AttributeSet attrs) {super(context, attrs);init();}public MeshView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);init();}@SuppressLint("NewApi")public MeshView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {super(context, attrs, defStyleAttr, defStyleRes);init();}@Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);flagWave();k+=0.1f;canvas.drawBitmapMesh(bitmap, WIDTH, HEIGHT, verts, 0, null, 0, null);if (isStart) {invalidate();}}public void startAnim() {isStart=true;requestLayout();}public void stopAnim() {isStart=false;}private void init() {bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pic);float bitmapHeight=bitmap.getHeight();float bitmapWidth=bitmap.getHeight();int index=0;for (int y = 0; y <= HEIGHT; y++) {float fy=bitmapHeight*y/HEIGHT;for (int x = 0; x <= WIDTH; x++) {float fx=bitmapWidth*x/WIDTH;origs[index*2+0]=verts[index*2+0]=fx;origs[index*2+1]=verts[index*2+1]=fy;index++;}}}private void flagWave() {for (int j = 0;j <= HEIGHT; j++) {for (int i = 0; i <= WIDTH; i++) {verts[ (j*(WIDTH+1)+i )*2+0 ]+=0;float offsetY=(float) Math.sin( i*1.0f/WIDTH*2*Math.PI + Math.PI*k);//k 实现周期变化verts[ (j*(WIDTH+1)+i )*2+1 ]=origs[ ( j*WIDTH+i )*2+1 ]+offsetY*100; //100 振幅}}}}
0 0
- android drawBitmapMesh
- understanding drawBitmapMesh on android
- android drawBitmapMesh and drawVertices
- Android drawBitmapMesh 扭曲图像
- Android中DrawBitmapMesh用法小记
- Android drawBitmapMesh扭曲图像
- Android之图像处理drawBitmapMesh
- Android Canvas的drawBitmapMesh实现扭曲图像
- android drawBitmapMesh()图片旗帜飘扬效果
- Android:使用drawBitmapMesh方法产生水波(一)
- 初学Android,图形图像之使用drawBitmapMesh扭曲图像(三十二)
- Android图形图画学习(7)——drawBitmapMesh
- Android 图片特效处理:drawBitmapMesh——图像扭曲+动感
- Android图像处理(五)镜像、倒影、drawBitmapMesh实现旗帜飘扬效果
- 使用drawBitmapMesh扭曲图片
- drawBitmapMesh扭曲图片
- 使用 drawBitmapMesh 扭曲图片
- 使用canvas.drawBitmapMesh扭曲图像
- ASP.NET MVC图片管理(上传,预览与显示)
- Android的init过程(二):初始化语言(init.rc)解析
- 怎样按层次打印二叉树
- OpenGL ES教程系列(经典合集)
- SVN 提交文件相关
- android drawBitmapMesh
- Android性能优化典范C1
- 1000赞的程序员高薪职业建议
- 机器学习 文章收集整理
- 使用tablesorter.js给table添加排序功能
- 解决 ClickOnce 发布出现: 清单中的引用与下载的程序集 *.exe 的标识不匹配 问题
- matlab读写文件
- Ubuntu 上安装OpenCV,编译程序
- Android中UI线程与后台线程交互设计的5种方法