开发者

Should UIImageJPEGRepresentation act the same on every iOS device?

I'm resizing an UIImage using the MGImageUtilities library (using the imageScaledToFitSize method). After the resize, if I print the size of the new UIImage created, the size is as expected.

After this first operation, I send the compressed image (UIImageJPEGRepresentation(sca开发者_JS百科ledImage, 0.7)) to a web service using the ASIHTTP lib.

With an iPad, the image is stored on the server with the expected size. When I run the same code on an iPod (4gen) the image is stored bigger than it's original version... Do you have any hint for me?


I feel comfortable making the following generalization: running on the same exact iOS version, and using the same exact input UIImage, I would expect you to get exactly the same bytes from UIImageJPEGRepresentation with the same quality param on it.*

When you say the image stored is bigger, you mean the file size, right? Not the actual image dimensions? What is the "expected size" (why do you expect it)? Are you sure the input source images are identical in this case?


*N.B. All that said, a JPEG encoder's only contract is that it spits out a valid JPEG at the correct dimensions from the source image. I don't work at Apple. The internals of the API beyond what is documented is free to behave in any random way, particularly across versions, and it's possible that there are per-device optimizations (etc) in the encoders, like using differing hand-built assembly for some of the arm platforms, or environment-specific runtime choices that the encoder makes.


The MGImageUtilities is resizing the UIImage with a twist, it apply the retina display DPI to the image. Instead of 72pixel/inch, it apply 144p/i. So I searched on the net for a better lib and I think I found something really useful: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜