Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between methods to scale a bitmap

There are at least two methods to scale a bitmap in Android, One is to use "inScaled, inDensity, inTargetDensity" in "BitmapFactory.Options" when decode a bitmap source. The other is to use a "Matrix" in "Bitmap.createBitmap".

What I am curious is what the difference between these two method is? What about the quality of produced bitmap? And what about the memory usage? etc...

like image 251
Henry Avatar asked Oct 20 '10 09:10

Henry


1 Answers

Using BitmapFactory with the proper inScale options will allow you to be more memory efficient than using either Bitmap.createScaledBitmap() or Bitmap.createBitmap() with a matrix scale. However, it is more complicated.

Check out How do I scale a streaming bitmap in-place without reading the whole image first? for details.

like image 97
emmby Avatar answered Sep 18 '22 16:09

emmby