Recently entered the new company internship, when looking at the project code to see the previous colleague is so written code to get the size of bitmap:
return Bitmap.getrowbytes () * bitmap.getheight ();//Get size and return
It feels strange why this is calculated instead of calling Bitmap.getbytecount directly ();
After reviewing the document, it is not known that the project is minsdk=8,targetsdk=19 and therefore cannot be called directly, but written in this way. However, I still feel that this is not rigorous, because the API level 12 after the version of the new method is still used.
Here's a summary of the code to get the bitmap image size:
public int getbitmapsize (Bitmap Bitmap) {if (Build.VERSION.SDK_INT >= build.version_codes. KITKAT) {//api 19return bitmap.getallocationbytecount ();} if (Build.VERSION.SDK_INT >= build.version_codes. HONEYCOMB_MR1) {//api 12return bitmap.getbytecount ();} return Bitmap.getrowbytes () * Bitmap.getheight ();//earlier version}
This article is from the "Flying Cat" blog, be sure to keep this source http://flyingcat2013.blog.51cto.com/7061638/1564228
Android gets the size of bitmap