UIImageWriteToSavedPhotosAlbum saves to wrong size and quality

前端 未结 2 1396
别跟我提以往
别跟我提以往 2020-11-29 07:54

I\'m trying to take a screen shot of my app\'s current view and save it to photo album (to then be emailed or MMS\'ed).

UIGraphicsBeginImageContext(self.vie         


        
2条回答
  •  时光说笑
    2020-11-29 08:13

    I found a decent workaround, which is to essentially rewrap the UIImage as a PNG, then save the rewrapped version. Code looks something like this:

    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
    

提交回复
热议问题