1. 程式人生 > >Android: creating a Bitmap with SurfaceView content

Android: creating a Bitmap with SurfaceView content

draw your SurfaceView onto a Canvas that's backed by a Bitmap?

// be sure to call the createBitmap that returns a mutable BitmapBitmap b =Bitmap.createBitmap(100,100,Bitmap.Config.ARGB_8888);Canvas c =newCanvas(b);
    yourSurfaceView.draw(c);
 it's not possible with SurfaceViews because the drawing process is done in a thread and the canvas is obtained from the SurfaceHolder. It is used this way: canvas = surfaceHolder.lockCanvas(null); synchronized(surfaceHolder) { doDraw(canvas); }