Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why PNG compression is that much slower than JPEG on Android?

Tags:

I've been toying with Android Bitmaps a bit and found out, that PNG compression takes much more time than even highest quality JPEG one. Much much more. On my device it can be roughly up to 10 seconds against 1.

AFAIK, PNG is basically filtered strings of pixels compressed with deflate. Well, finding the best filter for each string might be time consuming task, but there can be compromise established between speed and compression effectiveness. It shouldn't be that slower than JPEG. How come it is?

Maybe it's the other way around. Is there some ultra-fast JPEG implementation on Android?

UPDATE: I realy just do things like

mBitmap.compress(CompressFormat.JPEG, 100, stream); 

and

mBitmap.compress(CompressFormat.PNG, 100, stream); 
like image 323
akalenuk Avatar asked Jun 03 '13 10:06

akalenuk


People also ask

Is PNG slower than JPG?

In general, PNG is a higher-quality compression format. JPG images are generally of lower quality, but are faster to load. These factors affect whether you decide to use PNG or JPG, as does what the image contains and how it will be used.

Does PNG compression lose quality?

The biggest advantage of PNG over JPEG is that the compression is lossless, meaning there is no loss in quality each time it is opened and saved again. PNG also handles detailed, high-contrast images well.

Should I save as JPEG or PNG?

The general rule is to use JPGs for photographs, images that don't have a transparent background, and other memory intensive files. And to choose PNGs for graphics, files with transparent backgrounds, and other images where clarity and color vibrancy are important.


1 Answers

I've tested my project on emulator with much bigger pictures and though PNG compression was little slower, there was no drastic difference in performance. Therefore it should be due to the hardware acceleration, as told by BitBank in the comment.

like image 68
akalenuk Avatar answered Sep 22 '22 12:09

akalenuk