Log in or register to post comments

how to capture the screen?

December 15, 2010 - 2:27am #1

I will add a overlay with buttons to the app for control. One of the buttons is to capture the screen(camera view and gl view,with out the overlay). how to do that?

thanks in advnced

Re: how to capture the screen?

December 21, 2010 - 11:58pm #6

I keep working for it,but not succesed till now

Re: how to capture the screen?

December 18, 2010 - 4:12am #5

I came up with an idea. I thought I didn't get the correct image because the opengl image data is in video memory. maybe the glReadPixcels() function could help!!

Re: how to capture the screen?

December 17, 2010 - 2:31am #4

I' ve tried,but what I get is only a empty black image . here is the code:

Bitmap image = Bitmap.createBitmap( 800, 480, Bitmap.Config.ARGB_8888);
mGlView.draw(new Canvas(image));

But I can get correct result in the overlay view by this way .
mGlView is rendered in native code, I think this is the defference betewwn mGlView and my overlay view . I need more help~~

Re: how to capture the screen?

December 15, 2010 - 7:37am #3

I don't have any experience with this, but this method looks promising. In most cases, the OpenGL view will contain both the camera image and the 3D content, so rendering that single view into a bitmap should work. However, on some devices the camera image may be rendered in a separate layer. I believe what you want to do is cycle through all the application's views, drawing them into the bitmap from back to front. That will cover both cases.

If you want to have buttons on top of everything, but don't want to render those buttons into the screenshot, I suggest keeping them in a separate view that is overlaid on top of everything. That way, when you cycle through the views to draw them into your bitmap, you can simply do a check and skip your button layer.

Let me know if this makes sense!

- Kim

Re: how to capture the screen?

December 15, 2010 - 6:05am #2

I've found a function to convert a View to a bitmap,here is the code:

public static Bitmap loadBitmapFromView(View v) {
Bitmap b= Bitmap.createBitmap( v.getLayoutParams().width,v.getLayoutParams().height, Bitmap.Config.ARGB_8888);
Canvas c= new Canvas(b);
v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height); v.draw(c);
return b;
}

but I still have no idea about converting a view that include camera view and opengl view to a bitmap

Log in or register to post comments