22

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);
akalenuk
  • 3,815
  • 4
  • 34
  • 56
  • 1
    You should put some code to show how you compress. – Lukas Knuth Jun 03 '13 at 11:43
  • 25
    JPEG can be hardware accelerated, PNG is always done in software. JPEG takes a constant amount of time to process. 90+% of the time encoding and decoding PNG is spent in the flate codec. The filtering takes a trivial amount of time. Deflating at the highest quality level takes a long time because it tries multiple methods to get the best compression. – BitBank Jun 03 '13 at 21:51
  • Actually, Skia does support JPEG hardware acceleration. I should check my code on an emulator then. If performance gap lowers, then it must be it. – akalenuk Jun 04 '13 at 05:17

1 Answers1

6

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.

akalenuk
  • 3,815
  • 4
  • 34
  • 56