Android Bitmap Size Get getBitmapSize(Bitmap bitmap)

Here you can find the source of getBitmapSize(Bitmap bitmap)

Description

Get the size in bytes of a bitmap in a BitmapDrawable.

Declaration

@TargetApi(12)
public static int getBitmapSize(Bitmap bitmap) 

Method Source Code

//package com.java2s;
import android.annotation.TargetApi;

import android.graphics.Bitmap;

import android.os.Build;

public class Main {
    /**//w w w .  j av  a  2s. c om
     * Get the size in bytes of a bitmap in a BitmapDrawable.
     */
    @TargetApi(12)
    public static int getBitmapSize(Bitmap bitmap) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
            return bitmap.getByteCount();
        }
        // Pre HC-MR1
        return bitmap.getRowBytes() * bitmap.getHeight();
    }
}

Related

  1. computeSampleSize(int width, int height, int minSideLength, int maxNumOfPixels)
  2. computeSampleSize(float scale)
  3. computeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
  4. computeSampleSizeLarger(int w, int h, int minSideLength)
  5. computeSampleSizeLarger(float scale)
  6. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  7. calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
  8. computeInitialSampleSize( BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
  9. computeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)