How to save image on photos in iPhone without quality loss?

The quality of the saved image will lose when I use this method ...

UIImage *img=imageview1.image;
UIImageWriteToSavedPhotosAlbum(img,nil,nil,nil);
+3
source share
3 answers

You need to wrap the image in a PNG view so that it is saved in the photo library in PNG format, and not in JPG format.

I used the following code based on the code from Ben Weiss: UIImageWriteToSavedPhotosAlbum saves the wrong size and quality for comparing sides.

// Image contains a non-compressed image stored within my Documents directory
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
NSData* imdata = UIImagePNGRepresentation ( image ); 
UIImage* im2 = [UIImage imageWithData:imdata]; 
UIImageWriteToSavedPhotosAlbum(im2, nil, nil, nil); 

The image will be saved in PNG format in the Photo Library so that it can be obtained / shared later in full quality.

+6
source

Function


NSData * UIImageJPEGR (  UIImage * ,  CGFloat compressionQuality
);

( 1).

NSData , JPEG (, writeToURL: atomically: NSData​​CODE>).

.PNG UIImagePNGR.

: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIImageJPEGRepresentation

+3

, SDK, , + , . , - , SDK ( )? . , .

+1
source

Source: https://habr.com/ru/post/1736028/


All Articles