I want to be able to take a snapshot of a preview camera screen being displayed on a SurfaceView. I know it has something to do with the onPreviewFrame()
method and this returns a byte array in YUV format but I have no idea how to call the onPreviewFrame() method on it's own.
I have used it in conjunction with Camera.setPreviewCallback()
but this is a continuous thing that keeps generating the image, I need it to do it once on an onClick()
, to pretty much take a photo without making the preview window stop. Any ideas?
For anybody else with a similar problem to this I solved it by using the setOneShotPreviewCallback()
method on the camera object to give me a byte[]
with the information for the image. with that its can be used to create a YUV and then compressed to bitmap or whatever you need.
Capture the preview image into a canvas and hold a lock to it. You can then easily save to a BitMap Refer this post for complete explanation with sample code http://www.anddev.org/using_camerapreview_to_save_a_picture_on_disk-t226.html
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.