1

i want to copy surfaceview to bitmap , but just get black color (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);
zhu qing
  • 33
  • 1
  • 5

1 Answers1

-2

Use the surfaceview.getDrawingCache() will get Bitmap.

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
Seachaos
  • 40
  • 1
  • 2
  • I hv a surfaceview with white background. When I draw something on it and do getDrawingCache(), I am getting white bitmap not whatever I drawn on surfaceview – Braj Sep 13 '13 at 11:13
  • 1
    Surfaceview is not an actuaally a view so getDrawingCache() return black screen – Vinesh Chauhan Jan 30 '18 at 05:13