List of usage examples for android.graphics Bitmap getByteCount
public final int getByteCount()
From source file:Main.java
public static int getByteCount(Bitmap bitmap) { return bitmap.getByteCount(); }
From source file:Main.java
static int getByteCount(Bitmap paramBitmap) { return paramBitmap.getByteCount(); }
From source file:Main.java
public static byte[] bitmapToByteArray(Bitmap bitmap) { int bytes = bitmap.getByteCount(); ByteBuffer buf = ByteBuffer.allocate(bytes); bitmap.copyPixelsToBuffer(buf);/* w w w . j a v a 2 s.c om*/ byte[] byteArray = buf.array(); return byteArray; }
From source file:Main.java
public static byte[] bitmapToArray(Bitmap b) { int bytes = b.getByteCount(); ByteBuffer buffer = ByteBuffer.allocate(bytes); //Create a new buffer b.copyPixelsToBuffer(buffer); //Move the byte data to the buffer byte[] array = buffer.array(); //Get the underlying array containing the data. return array; }
From source file:Main.java
public static String convertBitmapToBase64(Bitmap bitmap) { final int size = bitmap.getByteCount(); ByteBuffer dst = ByteBuffer.allocate(size); bitmap.copyPixelsToBuffer(dst);/* w ww . j av a 2 s . c om*/ return Base64.encodeToString(dst.array(), Base64.DEFAULT); }
From source file:Main.java
public static byte[] getBytes(Bitmap bitmap) { int byteCount = bitmap.getByteCount(); ByteBuffer buffer = ByteBuffer.allocate(byteCount); bitmap.copyPixelsToBuffer(buffer);/* w ww . j a v a 2 s .c om*/ buffer.rewind(); byte[] data = new byte[byteCount]; buffer.get(data); return data; }
From source file:Main.java
/** * Converts bitmap to the byte array without compression * @param bitmap source bitmap//w ww .j a v a 2 s. c om * @return result byte array */ public static byte[] convertBitmapToByteArrayUncompressed(Bitmap bitmap) { ByteBuffer byteBuffer = ByteBuffer.allocate(bitmap.getByteCount()); bitmap.copyPixelsToBuffer(byteBuffer); byteBuffer.rewind(); return byteBuffer.array(); }
From source file:Main.java
public static int getSizeInBytes(Bitmap bitmap) { if (android.os.Build.VERSION.SDK_INT >= 12) { return bitmap.getByteCount(); } else {//from w ww .j a v a2s .co m return bitmap.getRowBytes() * bitmap.getHeight(); } }
From source file:Main.java
public static byte[] bitmapToBytes(Bitmap b) { //calculate how many bytes our image consists of. int bytes = b.getByteCount(); //or we can calculate bytes this way. Use a different value than 4 if you don't use 32bit images. //int bytes = b.getWidth()*b.getHeight()*4; ByteBuffer buffer = ByteBuffer.allocate(bytes); //Create a new buffer b.copyPixelsToBuffer(buffer); //Move the byte data to the buffer byte[] array = buffer.array(); return array; }
From source file:Main.java
public static byte[] bitmapToByteArray(Bitmap bitmap) { //int numBytes = bitmap.getWidth() + bitmap.getHeight() * 4; int numBytes = bitmap.getByteCount(); ByteBuffer byteBuffer = ByteBuffer.allocate(numBytes); bitmap.copyPixelsToBuffer(byteBuffer); return byteBuffer.array(); }