List of usage examples for java.io ByteArrayOutputStream toByteArray
public synchronized byte[] toByteArray()
From source file:Main.java
public static byte[] getImageBytes(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); return stream.toByteArray(); }
From source file:Main.java
public static byte[] bitmapToByteArray(Bitmap bitmap) { if (bitmap == null) { return null; }/* w w w .j a v a 2 s. c o m*/ ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); }
From source file:Main.java
public final static byte[] BitmapChangeByte(Bitmap btm) { if (btm == null) { return null; }//from ww w . j a v a 2s . c om ByteArrayOutputStream baos = new ByteArrayOutputStream(); btm.compress(CompressFormat.PNG, 100, baos); byte[] data2 = baos.toByteArray(); return data2; }
From source file:Main.java
public static byte[] getBitmapData(Bitmap bmp) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bmp.compress(CompressFormat.JPEG, 100, bos); byte[] bitmapdata = bos.toByteArray(); return bitmapdata; }
From source file:Main.java
public static byte[] getBytesFromBitmap(Bitmap bitmap) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos); byte[] bytes = bos.toByteArray(); return bytes; }
From source file:Main.java
public static final String bitMapToString(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] b = baos.toByteArray(); String temp = Base64.encodeToString(b, Base64.DEFAULT); return temp;//w w w .ja va2s . c om }
From source file:Main.java
/** * Converts a bitmap to a byte array/* ww w.j a v a 2s. c o m*/ * @param bitmap * @return */ public static byte[] getImageBytes(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream); return stream.toByteArray(); }
From source file:Main.java
/** * Converts a Bitmap to a byteArray./*w w w. jav a 2 s .c om*/ * @return byteArray */ public static 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 byte[] concatenateTwoByteArrays(byte a[], byte b[]) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(a);/*from w w w .jav a 2 s.c om*/ outputStream.write(b); return outputStream.toByteArray(); }
From source file:Main.java
public static String bitmapToString(Bitmap bm, int rate) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, rate, baos); byte[] b = baos.toByteArray(); return Base64.encodeToString(b, Base64.DEFAULT); }