Android examples for Graphics:Bitmap Byte Array
Returns the estimated memory usage in bytes for a bitmap.
//package com.java2s; import java.lang.reflect.Method; import android.graphics.Bitmap; public class Main { /** Returns the estimated memory usage in bytes for a bitmap. Calls bitmap.getByteCount() if that method * is available (in API level 12 or higher), otherwise returns 4 times the number of pixels in the bitmap. *//* w w w. jav a 2s.c o m*/ public static int getBitmapByteCount(Bitmap bitmap) { try { Method byteCountMethod = Bitmap.class.getMethod("getByteCount"); return (Integer) byteCountMethod.invoke(bitmap); } catch (Exception ex) { return 4 * bitmap.getWidth() * bitmap.getHeight(); } } }