3n.
3n.

Reputation: 1671

Saving a PNG (or good quality JPG) image to the Photos Library

Scenario Saving a 320x480 view as an image in the user's saved photos album.

Problem Always saves a 800x?, low quality JPG.

Using the normal renderInContext/UIImageWriteToSavedPhotosAlbum method to save a view to the library. I've tried converting the UIImage to a PNGRepresentation then using that data to make a new UIImage - it still just saves a JPG in the library.

I could possibly solve this problem by upsizing my view to 800px tall then take the "screenshot" - but that's going to be a lot of work.

Has anyone been able to solve this low-quality saved image problem? I've seen threads all over about it but the always die off without any solid ideas.

Thanks, Ian

Upvotes: 1

Views: 2865

Answers (1)

user1114055
user1114055

Reputation:

The best answer of this question can be found here. I'll paste it just in case something happens in the future which would make the link invalid:

UIImage* im = [UIImage imageWithCGImage:myCGRef]; // make image from CGRef
NSData* imdata =  UIImagePNGRepresentation ( im ); // get PNG representation
UIImage* im2 = [UIImage imageWithData:imdata]; // wrap UIImage around PNG representation
UIImageWriteToSavedPhotosAlbum(im2, nil, nil, nil); // save to photo album

Thanks to Ben Weiss for this.

Upvotes: 4

Related Questions