Android Utililty Methods Bitmap Size Get

List of utility methods to do Bitmap Size Get

Description

The list of methods to do Bitmap Size Get are organized into topic(s).

Method

intcomputeSampleSizeLarger(float scale)
compute Sample Size Larger
int initialSize = (int) Math.floor(1f / scale);
if (initialSize <= 1)
    return 1;
return initialSize <= 8 ? prevPowerOf2(initialSize)
        : initialSize / 8 * 8;
intgetBitmapSize(Bitmap bitmap)
Get the size in bytes of a bitmap in a BitmapDrawable.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
    return bitmap.getByteCount();
return bitmap.getRowBytes() * bitmap.getHeight();
intcalculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
calculate In Sample Size
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
    if (width > height) {
        inSampleSize = Math.round((float) height
                / (float) reqHeight);
    } else {
...
intcalculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
calculate In Sample Size
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
    final int heightRatio = Math.round((float) height
            / (float) reqHeight);
    final int widthRatio = Math.round((float) width
            / (float) reqWidth);
...
intcomputeInitialSampleSize( BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
compute Initial Sample Size
double w = options.outWidth;
double h = options.outHeight;
int lowerBound = (maxNumOfPixels == UNCONSTRAINED) ? 1 : (int) Math
        .ceil(Math.sqrt(w * h / maxNumOfPixels));
int upperBound = (minSideLength == UNCONSTRAINED) ? 128
        : (int) Math.min(Math.floor(w / minSideLength),
                Math.floor(h / minSideLength));
if (upperBound < lowerBound) {
...
intcomputeSampleSize(BitmapFactory.Options options, int minSideLength, int maxNumOfPixels)
compute Sample Size
int initialSize = computeInitialSampleSize(options, minSideLength,
        maxNumOfPixels);
int roundedSize;
if (initialSize <= 8) {
    roundedSize = 1;
    while (roundedSize < initialSize) {
        roundedSize <<= 1;
} else {
    roundedSize = (initialSize + 7) / 8 * 8;
return roundedSize;
intgetBitmapSize(Bitmap bitmap)
get Bitmap Size
return bitmap.getRowBytes() * bitmap.getHeight();
BitmapFactory.OptionsgetBitmapSize(String strImagePath)
get Bitmap Size
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(strImagePath, options);
return options;
BitmapFactory.OptionsgetBitmapSize(String strImagePath, boolean checkOrientation)
get Bitmap Size
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(strImagePath, options);
if (checkOrientation) {
    int degree = getExifDegree(strImagePath);
    if (degree == 90 || degree == 270) {
        int temp = options.outWidth;
        options.outWidth = options.outHeight;
...