开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜