简体   繁体   English

iPhone:使用叠加视图捕获iOS相机

[英]iPhone: Capture iOS Camera with Overlay View

In my application i am capturing picture through camera with overlay view & in the overlay view, there is a custom button through which i want to capture the whole screen.Overlay view is transparent at some points where i want to capture image. 在我的应用程序中,我正在通过具有叠加视图和叠加视图的相机捕获图片,其中有一个自定义按钮,我想通过该按钮捕获整个屏幕。叠加视图在我要捕获图像的某些点是透明的。 I am doing it like this: 我这样做是这样的:

    - (IBAction)captue:(id)sender
    {
        [self setBackgroundColor:[UIColor clearColor]];        
        UIGraphicsBeginImageContext(self.frame.size);
        [self.layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
    }

It is capturing the image of overlay view but at the camera view (the view where overlay is transparent and i want to show camera view there) it is capturing black color instead of a photo. 它正在捕获叠加视图的图像,但是在摄影机视图(叠加层是透明的并且我要在此处显示摄像机视图的视图)中,它捕获的是黑色而不是照片。 Anyone please tell me am i doing something wrong? 有人告诉我我做错了吗?

Using AVFoundationFramework to fix your problem. 使用AVFoundationFramework可以解决您的问题。

Referred this link: http://code4app.net/ios/Camera-With-AVFoundation/5003cb1d6803fa9a2c000000 引用了此链接: http : //code4app.net/ios/Camera-With-AVFoundation/5003cb1d6803fa9a2c000000

Hope this link helpful for you. 希望此链接对您有所帮助。

I found Screen capture is the one of the thing to capture camera view with overlay. 我发现屏幕捕获是捕获带有叠加层的摄像机视图的一件事。 But i didn't get the preview layer in screen captured video(in case video recording). 但是我没有在屏幕捕获的视频中获得预览层(以防万一录像)。 Look at MyAVControllerDemo code to get clear idea and i used IAScreenCaptureView to capture video, or simple snap shot. 查看MyAVControllerDemo代码以获得清晰的主意,我使用IAScreenCaptureView捕获视频或简单的快照。 Now working properly. 现在可以正常工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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