开发者

How Do I Take Still Images?

开发者 https://www.devze.com 2023-03-23 01:59 出处:网络
i wa开发者_开发百科nt to add a camerapreviewlayer and a take photo action but i dont know how.

i wa开发者_开发百科nt to add a camerapreviewlayer and a take photo action but i dont know how. Can someone help me. Im new in Xcode


If it's an CALayer (which I'm pretty sure it is, but I'll verify it now), you can do this:

UIGraphicsBeginImageContext();
[yourCameraPreviewLayer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGrahpicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Edit: I presume you're using AVCaptureVideoPreviewLayer, then it is a CALayer, so above should work.


Here is an example of taking a photo: https://github.com/fulldecent/FDTake

0

精彩评论

暂无评论...
验证码 换一张
取 消