简体   繁体   中英

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!

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!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM