最終更新:2016-01-04 (月) 15:06:13 (3007d)
TextureView.lockCanvas
Top / TextureView.lockCanvas
メモ
- It is important to note that only one producer can use the TextureView. For instance, if you use a TextureView to display the camera preview, you cannot use TextureView.lockCanvas() to draw onto the TextureView at the same time.
例
public class hoge extends TextureView implements TextureView.SurfaceTextureListener,Runnable{ @Override public void onSurfaceTextureAvailable(SurfaceTexture surface,int width,int height) { //スレッドの開始 thread=new Thread(this); thread.start(); } public void run() { while(thread!=null) { long currentTime=System.currentTimeMillis(); onTick(); try { Thread.sleep(30-currentTime%30); } catch (Exception e) { } } } //定期処理 private void onTick() { Canvas canvas=lockCanvas(); if (canvas==null) return; canvas.drawColor(Color.WHITE); canvas.drawBitmap(image,px-120,py-120,null); unlockCanvasAndPost(canvas); } }