Andrew Furniss
Andrew Furniss

Reputation: 69

Android Camera Preview Screenshot

I have implemented a custom camera using the Android docs. Everything works well and I use the cameras takePicture() method along with callbacks and all works fine. I found that it takes around 0-2 seconds for the callback to finish so I was wondering if there was any way to take a screenshot of the surfaceview contents after stopping the preview? I have looked around and it doesn't seem to be possible. I tried implementing a GLSurfaceView but didn't have any luck. Any feedback would be greatly appreciated, thanks!

Upvotes: 0

Views: 427

Answers (1)

Gueorgui Obregon
Gueorgui Obregon

Reputation: 5087

If have facing some delays in my custom camera app when taking picture, the problem was saving the bitmap.

takedPictureBitmap.compress(Bitmap.CompressFormat.PNG, 90, fOut); // saving the Bitmap to a path compressed as a PNG with 90% compression rate

Was delaying for 6 seconds until i see the preview again. I found that i'm requesting camera with JPEG format, so when the picture is taked, compressing the image to different format was taking to long. So i change compress to :

takedPictureBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut); // saving the Bitmap to a path compressed as a JPEG with 85% compression rate

And I saw the preview instantly :)

I hope it help!!

Upvotes: 1

Related Questions