来自UIGraphicsGetImageFromCurrentImageContext()的更高质量的图像

Fly*_*ana 14 core-graphics objective-c ios

我目前正在使用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);
Run Code Online (Sandbox Code Playgroud)

Wai*_*ain 46

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

UIGraphicsBeginImageContextWithOptions(size, NO, 0);
Run Code Online (Sandbox Code Playgroud)