2012-06-27 100 views
1

我想surfaceview複製到的位圖,但只是讓黑色(FF000000)如何複製surfaceview爲位圖

//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); 

回答

-2

使用surfaceview.getDrawingCache()將得到位圖。

+0

我hv與白色背景的surfaceview。當我在它上面畫一些東西並做getDrawingCache()時,我得到的是白色位圖,而不是我在surfaceview上繪製的任何東西 – Braj

+0

Surfaceview並不是一個真正的視圖,所以getDrawingCache()返回黑色屏幕 –

相關問題