开发者

Is there any diffrence betweeen memory size of an UIImage and its NSData?

开发者 https://www.devze.com 2023-02-07 18:23 出处:网络
I am converting an UIImage to NSData and u开发者_StackOverflowploading the NSData to server. Is there any reduced of memory size by converting into NSData or it is the same memory that an UIImage occu

I am converting an UIImage to NSData and u开发者_StackOverflowploading the NSData to server. Is there any reduced of memory size by converting into NSData or it is the same memory that an UIImage occupied.

Please help me

Thank you, Madan Mohan.


Converting an UIImage to NSData via UIImageJPEGRepresentation can have a dramatic effect on the size. UIImageJPEGRepresentation requires a compression factor parameter and based on that value the NSData returned will be bigger or smaller.

In my testing, UIImageJPEGRepresentation(image, 1.0f) more than doubled the number of bytes. To reduce the size, use a number less than 1.0, but be aware that this will reduce image quality.

UIImagePNGRepresentation will return an uncompressed PNG version of the image, which will be much larger than the original JPEG.

0

精彩评论

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

关注公众号