
UIGraphicsBeginImageContext(captureVIEw.bounds.size); [captureVIEw.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *screenshot = UIGraphicsGetimageFromCurrentimageContext(); UIImageWritetoSavedPhotosAlbum(screenshot,nil,nil); UIGraphicsEndImageContext();解决方法 我想你需要在视网膜分辨率(960×640或2048×1536)中捕获UIVIEw / UIWindow使用UIGraphicsBeginImageContextWithOptions并设置其缩放参数0.0f使其以原始分辨率捕获(适用于iPhone 4及更高版本或iPad 3的视网膜).
此代码以原始分辨率捕获您的UIVIEw
CGRect rect = [captureVIEw bounds];UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);CGContextRef context = UIGraphicsGetCurrentContext();[captureVIEw.layer renderInContext:context]; UIImage *capturedImage = UIGraphicsGetimageFromCurrentimageContext();UIGraphicsEndImageContext();
这个对全屏(关键窗口)也一样
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];CGRect rect = [keyWindow bounds];UIGraphicsBeginImageContextWithOptions(rect.size,0.0f);CGContextRef context = UIGraphicsGetCurrentContext();[keyWindow.layer renderInContext:context]; UIImage *capturedScreen = UIGraphicsGetimageFromCurrentimageContext();UIGraphicsEndImageContext();
这样可以在应用程序的文档文件夹中以99%的质量保存Upgmage的jpg格式
Nsstring *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:[Nsstring stringWithFormat:@"documents/capturedImage.jpg"]]; [UIImageJPEGRepresentation(capturedImage,0.95) writetofile:imagePath atomically:YES];总结
以上是内存溢出为你收集整理的iphone – iPad上的低质量捕获视图上下文全部内容,希望文章能够帮你解决iphone – iPad上的低质量捕获视图上下文所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)