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.
精彩评论