如何将surfaceview复制到位图

时间:2012-06-27 06:41:06

标签: android bitmap

我想将surfaceview复制到位图,但只获得黑色(ff000000)

    //this.surView is my SurfaceView 
    Bitmap bitmap =Bitmap.createBitmap(this.surView.getWidth(), this.surView.getHeight(),      Bitmap.Config.RGB_565); 
      //this.can is my canvas
    this.can = this.surHolder.lockCanvas(new  Rect(0,0,this.surView.getWidth(), this.surView.getHeight()));
     this.can.setBitmap(bitmap);
     this.surView.draw(this.can);
     this.surHolder.unlockCanvasAndPost(can);
       // bitmap = Bitmap.createBitmap(bitmap);
                  //copy bitmap from (srcx,srcy) to (x,y) 
        bitmap = Bitmap.createBitmap(bitmap, srcx, srcy, cx, cy);

        this.ondrawImage(bitmap, x, y);

1 个答案:

答案 0 :(得分:-2)

使用surfaceview.getDrawingCache()将获取位图。