Get underlying NSData from UIImage

前端 未结 6 1297
感情败类
感情败类 2020-12-12 17:41

I can create UIImage from NSData using [UIImage imageWithData:] or [UIImage initWithData:] methods.

I wonder i

6条回答
  •  轮回少年
    2020-12-12 18:13

    NSData *imageData = UIImageJPEGRepresentation(image, 0.7); // 0.7 is JPG quality
    

    or

    NSData *imageData = UIImagePNGRepresentation(image);
    

    Depending if you want your data in PNG format or JPG format.

提交回复
热议问题