0

I have two surfaces views in a frame layout, which also contains a linear layout with some buttons. One of the buttons should be able to capture and save an image of the two surfaceviews. One surfaceview is a camera preview and the other is an opengl surface with a square in it. How would you go about taking the picture and saving it?

user3074140
  • 733
  • 3
  • 13
  • 30

1 Answers1

1

You can't read data back from a SurfaceView Surface. See e.g. this answer.

The way that you "capture" it is by rendering it to something you can read the pixels from. In your case, you'd grab a frame from the camera, render that to an offscreen pbuffer, then render the square with OpenGL ES onto the same pbuffer, and then grab that with glReadPixels(). Essentially you perform the Surface composition yourself.

Community
  • 1
  • 1
fadden
  • 51,356
  • 5
  • 116
  • 166