code: public static int bitmapSize(Bitmap bitmap) {
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
              return bitmap.getByteCount();
          } else {
              return bitmap.getRowBytes() * bitmap.getHeight();
          }
      }
docs: Calculating allocated memory for bitmap
  
  @param bitmap source bitmap
  @return size in bytes