android實現水波紋效果的例子
public class AnimActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(new PlasmaView(this)); } }class PlasmaView extends View implements View.OnTouchListener{
private Bitmap mBitmap; long time; long fps;public PlasmaView(Context context) { super(context); Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.mm); mBitmap = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Bitmap.Config.RGB_565); AnimRender.setBitmap(bmp); this.setOnTouchListener(this); } @Override protected void onDraw(Canvas canvas) { long ct = System.currentTimeMillis(); if(ct - time > 1000){ Log.v("Fps:" + String.valueOf(fps)); time = ct; fps = 0; } //fps++; fps += 20; AnimRender.render(mBitmap); canvas.drawBitmap(mBitmap, 0, 0, null); postInvalidate(); } @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub AnimRender.drop((int)event.getX(), (int)event.getY(), 1200); return false; }
}
class AnimRender{ public static native void setBitmap(Bitmap src); public static native void render(Bitmap dst); public static native void drop(int x, int y, int height);
static { System.loadLibrary("plasma"); }
}</pre>
本文由用戶 openkk 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!