除了这个问题之外,我正在使用AVCapture从camera.Everything捕获图像。
我需要最终捕获的图像,就像在camera.But中可见的一样,图像显示更多的区域(这不像在相机中可见).How我可以得到与最终的stillImageOutput相同的可见图像吗?
任何帮助都将不胜感激。
发布于 2015-02-03 21:32:42
使用视图/图像视图对象名称,而不是contentScrollview。这将帮助您渲染视图并为您提供图像。参考:https://charangiri.wordpress.com/2014/09/18/how-to-render-screen-taking-screen-shot-programmatically/
- (UIImage *) createScreenshotOfCompleteScreen
{
UIImage* image = nil;
UIGraphicsBeginImageContext(contentScrollview.contentSize);
{
CGPoint savedContentOffset = contentScrollview.contentOffset;
CGRect savedFrame = contentScrollview.frame;
contentScrollview.contentOffset = CGPointZero;
contentScrollview.frame = CGRectMake(0, 0, contentScrollview.contentSize.width, contentScrollview.contentSize.height);
if ([[NSString versionofiOS] intValue]>=7)
{
[contentScrollview drawViewHierarchyInRect:contentScrollview.bounds afterScreenUpdates:YES];
}
else
{
[contentScrollview.layer renderInContext: UIGraphicsGetCurrentContext()];
}
image = UIGraphicsGetImageFromCurrentImageContext();
contentScrollview.contentOffset = savedContentOffset;
contentScrollview.frame = savedFrame;
}
UIGraphicsEndImageContext();
return image;
}https://stackoverflow.com/questions/28297104
复制相似问题