Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better quality image from UIGraphicsGetImageFromCurrentImageContext()

I'm currently using UIGraphicsGetImageFromCurrentImageContext() to save a content's image to a user's camera roll, but the image quality is worse than if I do a screen shot in the simulator. Is there any way to improve it? And what format the saved image is in anyway? Bmp? Is there any way to change this?

Here's my save code:

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

UIImageWriteToSavedPhotosAlbum(originalImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
like image 966
Flying_Banana Avatar asked Aug 03 '13 07:08

Flying_Banana


1 Answers

Instead of using UIGraphicsBeginImageContext you should be using:

UIGraphicsBeginImageContextWithOptions(size, NO, 0);
like image 56
Wain Avatar answered Sep 29 '22 12:09

Wain