I am looking at image file formats and I would like to know which one of png, gif, jpeg, bmp, and tiff is the most efficient in terms of loading and displ开发者_开发问答aying the image data. I don't care so much about the file size on disk, just the amount of CPU needed to display the images on an embedded device like Android, iPhone, or a Windows Phone.
I imagine an uncompressed format would be the most efficient from a processing perspective, since you don't need any processing to decompress it. But you pay the cost of having a larger file size. BMP and TIFFs are the two uncompressed formats in the list of choices you gave.
For Android, the two preferred formats are very much JPEG and PNG. Use the former when lossy compression is okay (such as for pictures), the latter when you need the exact pixels to remain untouched (such as for UI graphical elements). GIF images are somewhat supported for loading, but should never be used for normal application resources. TIFF and BMP even more so.
I have a little experience with this from doing streaming webcam stuff. Unfortunately, my constraint was on the compression side. I found JPEG was surprisingly fast, PNG was only competitive when I reduced the compression level (to the minimum level actually), and then had to deal with the larger data size. Your version of the problem is on the decoding side, but also you may have to investigate the tradeoff between CPU vs. bandwidth on your own platform.
My point here though is that both JPEG and PNG have compression levels, and in particular for PNG, the compression level strongly affects the compression CPU usage, although it may have a lesser effect on decoding time. So it's not just a matter of format, but also the compression settings used for each format.
From the selection of jpeg, png, bmp and tiff jpeg usually is the fastest to load.
If you can't afford lossy compression png seems to be the second fastest, depending on the compression level you choose.
The decompression throughput is, in this case, appearently faster than loading from the HDD/SD
I tested it only on Desktop Computers, but on mobile the speeds should stay similar. Even though the mobile processors might not be as fast in decompression, the memory usually is slower too.
精彩评论