ios - 来自 UIGraphicsGetImageFromCurrentImageContext() 的更好质量的图像

标签 ios objective-c core-graphics

我目前正在使用 UIGraphicsGetImageFromCurrentImageContext() 将内容的图像保存到用户的相机胶卷中,但图像质量比我在模拟器中进行屏幕截图时差。有什么办法可以改善吗?保存的图像到底是什么格式? BMP?有什么办法可以改变吗?

这是我的保存代码:

CGSize size = [content bounds].size;
UIGraphicsBeginImageContext(size);
[[content layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *originalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

UIImageWriteToSavedPhotosAlbum(originalImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

最佳答案

而不是使用 UIGraphicsBeginImageContext 你应该使用:

UIGraphicsBeginImageContextWithOptions(size, NO, 0);

关于ios - 来自 UIGraphicsGetImageFromCurrentImageContext() 的更好质量的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18030323/

相关文章:

ios - 在另一个 View 中居中 View

objective-c - UISplitViewController Master/Detail 通信

iphone - 比较位置与NSMutableArray中的坐标

ios - 过滤结构时出错

iphone - UISearchBar 键盘外观

ios - Xcode 10,无法使用特定编码解码输入文件

objective-c - 边框模糊的 UIView

ios - iOS 7 上 UIView 的 Debug 和 Release 模式之间的绘图差异

ios - 如何镜像 UIBezierPath?

ios - 谷歌地图 API : Getting coordinates of current location iOS