Taking screen shot of a SurfaceView in android
Posted
by
Mostafa Imran
on Stack Overflow
See other posts from Stack Overflow
or by Mostafa Imran
Published on 2012-10-04T09:27:44Z
Indexed on
2012/10/04
9:37 UTC
Read the original article
Hit count: 189
android
I am using following method to taking screen shot of a particular view which is a SurfaceView.
public void takeScreenShot(View surface_view){
// create bitmap screen capture
Bitmap bitmap;
View v1 = surface_view;
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 0, bos);
byte[] imageData = bos.toByteArray();
}
the problem is its giving me the whole activity screen image. But I need to take screen shot of the particular view. I tried other ways but those give me a black screen as screen shot, some posts says that it requires rooted device. Can any one help me please. I'm in need of this solution. Help me....
© Stack Overflow or respective owner