Taking screen shot of a SurfaceView in android

后端 未结 4 963
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 19:30

I am using following method to taking screen shot of a particular view which is a SurfaceView.

public void takeScreenShot(View surface_view){

    // create          


        
4条回答
  •  遥遥无期
    2020-12-09 20:21

    Once you get the bitmap, you can copy only a part of it like this:

     private Bitmap copyBitmap(Bitmap src){
    
         //Copy the whole bitmap
         //Bitmap newBitmap = Bitmap.createBitmap(src);
    
         //Copy the center part only
         int w = src.getWidth();
         int h = src.getHeight();
         Bitmap newBitmap = Bitmap.createBitmap(src, w/4, h/4, w/2, h/2);
    
         return newBitmap;
        }
    

提交回复
热议问题