get Bitmap Size In Bytes - Android Graphics

Android examples for Graphics:Bitmap Byte Array

Description

get Bitmap Size In Bytes

Demo Code


//package com.java2s;
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.os.Build;

public class Main {
    @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
    public static int getSizeInBytes(Bitmap bitmap) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
            return bitmap.getByteCount();
        } else {// www. j  a  va  2s.c o m
            return bitmap.getRowBytes() * bitmap.getHeight();
        }
    }
}

Related Tutorials