質問

I took screenshot of overlay image with background camera controller. But background cameracontroller layer is hiding when taking picture

code:

CGRect rect = [previewView bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[previewView.layer renderInContext:context];   
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
 UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
役に立ちましたか?

解決

The camera preview layer is not a common CALayer and is not taken into account with render in context. Render in context works only with a kind of CALayer. The most effettive way is get a screenshot directly from the camera buffer.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top