开发者

UIImageWriteToSavedPhotosAlbum creates black thumbnail in camera roll

开发者 https://www.devze.com 2022-12-30 04:17 出处:网络
I am saving image in the camera roll using UIImageWriteToSavedPhotosAlbum but always get an black thumbnail even if the 开发者_运维问答picture is correct.

I am saving image in the camera roll using UIImageWriteToSavedPhotosAlbum but always get an black thumbnail even if the 开发者_运维问答picture is correct.

Do you have pointers to address this?

Thanks in advance for your help.

Regards,


I had the same problem. Drawing the image within a UIGraphicsImageContext solves the issue:



  CGRect rect = CGRectMake(0,0,100,100);
  UIImage *image = ((put here your image));

  UIGraphicsBeginImageContext(rect.size);
  [image drawInRect:rect];
  UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();  

  UIImageWriteToSavedPhotosAlbum(
      result, self, @selector(image:didFinishSavingWithError:contextInfo:),nil);

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号