How to save picture (applied glsl effects) captured by camera in Android?

1.2k views Asked by At

I have applied some effects to camera preview by OpenGL ES 2.0 shaders. Next, I want to save these effect pictures (grayscale, negative ...)

I call glReadPixels() in onDrawFrame(), create a bitmap based on the pixels I read from opengl frame buffer and then save it to device storage.

However, in this way, I only "snapshot" the camera effect preview. In other words, the saved image resolution (ex: 800*480) is not the same as the image taken by Camera.PictureCallback (ex: 1920 * 1080).

I know the preview size can be changed by setPreviewSize(), but it can't equal to picture size finally.

So, is it possible to use glsl shader to post process directly the image get by Camera.PictureCallback ? Or there is another way to achieve the same goal?

Any suggestion will be greatly appreciated. Thanks.

1

There are 1 answers

0
Alex Cohn On

Justin, this was my question about setPreviewTexture(), not a suggestion. If you send the pixel data as received from onPreviewFrame() callback, it will naturally be limited by supported preview sizes.

You can use the same logic to push the pixels from onPictureTaken() to a texture, but you should decode them into RGB from JPEG format.