List of usage examples for java.io ByteArrayOutputStream toByteArray
public synchronized byte[] toByteArray()
From source file:Main.java
public static byte[] bitmap2Bytes(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); return baos.toByteArray(); }
From source file:Main.java
public static byte[] bitmap2Array(Bitmap bmp) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static byte[] bitmapToBytes(Bitmap img) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); img.compress(Bitmap.CompressFormat.JPEG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static byte[] getByteArrayFromBitmap(Bitmap bmp) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 0, bytes); return bytes.toByteArray(); }
From source file:Main.java
/** * bitmap2Bytes/*from www . j a v a 2 s .co m*/ * * @param bm * @return */ public static byte[] bitmap2Bytes(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); }
From source file:Main.java
private static byte[] bitmap2Bytes(Bitmap bm) { if (bm == null) { return null; }//from ww w .j a v a2 s . com ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); }
From source file:Main.java
public static String bitmapToBase64String(Bitmap bm) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 80, bos); byte[] b = bos.toByteArray(); return Base64.encodeToString(b, Base64.DEFAULT); }
From source file:Main.java
public static byte[] bitmapToByteArray(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 200, stream); return stream.toByteArray(); }
From source file:Main.java
public static byte[] getBytes(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static String encodeBitmap(Bitmap bitmap, Bitmap.CompressFormat compressFormat) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(compressFormat, 100, baos); byte[] bytes = baos.toByteArray(); byte[] encodedImage = Base64.encode(bytes, Base64.DEFAULT); return new String(encodedImage); }