List of usage examples for java.io ByteArrayOutputStream toByteArray
public synchronized byte[] toByteArray()
From source file:Main.java
/** * Converts and Android bitmap file to an array of raw bytes that are ready to be sent over bluetooth, * wifi, usb, etc.//from www.ja v a 2 s. c om * * @param bitmap The bitmap to translate * @param format The format of the bitmap * @return The raw byte representation of the bitmap */ public static byte[] bitmapToRawBytes(Bitmap bitmap, CompressFormat format) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(format, 100, baos); byte[] result = baos.toByteArray(); return result; }
From source file:Main.java
public static synchronized byte[] bitmapToByteArray(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static final byte[] getImageByteArray(Bitmap bi) { byte[] data;/*from w w w . j a v a 2s. c om*/ ByteArrayOutputStream baos = new ByteArrayOutputStream(); bi.compress(Bitmap.CompressFormat.JPEG, 100, baos); data = baos.toByteArray(); return data; }
From source file:Main.java
public static byte[] getByteArray(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static byte[] convertBitmapToByte(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static byte[] getBitmap2Bytes(Bitmap photo) { if (photo == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); photo.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); }
From source file:Main.java
public static byte[] convertBitmap(Bitmap bitmap, int quality) { if (bitmap == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, baos); return baos.toByteArray(); }
From source file:Main.java
/** * Converts a given bitmap to byte array **//*from w w w. j a v a 2 s. co m*/ public static byte[] toBytes(Bitmap bmp) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static byte[] bitmapToBytes(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static byte[] getBytesFromBitmap(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream); return stream.toByteArray(); }