Łukasz Szpyrka
Łukasz Szpyrka

Reputation: 687

Getting camera preview (exactly what it displays)

Is there possibility to somehow capture picture which CameraPreview is displaying? For unknown reason, my camera preview is different then taken photo in vertical mode. In order to complete my app I need exact image in preview as photo taken. I know that issue is due to rotating photo by 90 degrees but question still remains - how to write into file camera preview (not photo taken).

Upvotes: 1

Views: 109

Answers (1)

Eddy Talvala
Eddy Talvala

Reputation: 18097

If you are using a SurfaceView, there's no way to get that image data.

However, if you are using a SurfaceTexture with Camera.setPreviewTexture, you can read back the OpenGL texture that SurfaceTexture is writing data into, and then save that to disk. Look up OpenGL tutorials or other questions on using glReadPixels.

If your issue is simply that the orientation of the photo taken is wrong, take a look at Camera.Parameters.setRotation, which lets you change the orientation of the picture captured.

Upvotes: 1

Related Questions