List of usage examples for java.io ByteArrayOutputStream ByteArrayOutputStream
public ByteArrayOutputStream()
From source file:Main.java
public static byte[] bmpToByteArray(Bitmap bitmap, boolean flag) { ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); bitmap.compress(android.graphics.Bitmap.CompressFormat.JPEG, 100, bytearrayoutputstream); if (flag)/* ww w. ja v a2 s. c om*/ bitmap.recycle(); byte abyte0[] = bytearrayoutputstream.toByteArray(); try { bytearrayoutputstream.close(); } catch (Exception exception) { exception.printStackTrace(); } return abyte0; }
From source file:Main.java
public static ByteArrayOutputStream getBitmapOutputStream(Bitmap b) { Bitmap immagex = b;//from w w w. j a v a 2 s. c o m ByteArrayOutputStream baos = new ByteArrayOutputStream(); immagex.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos; }
From source file:Main.java
public static byte[] changeBitmapToByte(Bitmap bm) { ByteArrayOutputStream baOut = new ByteArrayOutputStream(); bm.compress(CompressFormat.PNG, 100, baOut); return baOut.toByteArray(); }
From source file:Main.java
public static String bitmapToBase64(Bitmap bmp) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 75, byteArrayOutputStream); byte[] imgBytes = byteArrayOutputStream.toByteArray(); return Base64.encodeToString(imgBytes, Base64.DEFAULT); }
From source file:Main.java
public static byte[] decodeByteFromBitmap(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, baos); return baos.toByteArray(); }
From source file:Main.java
private static long getSizeOfBitmap(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); long length = baos.toByteArray().length / 1024; return length; }
From source file:Main.java
public static byte[] getByteFromBitmap(Bitmap bitmap, Bitmap.CompressFormat compressFormat) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(compressFormat, 100, baos); return baos.toByteArray(); }
From source file:Main.java
public static String bitmapToBase64(Bitmap bitmap) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); return Base64.encodeToString(byteArray, Base64.DEFAULT); }
From source file:Main.java
public static byte[] bitmapToByteArray(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] bytes = baos.toByteArray(); try {//from w w w . jav a 2s . co m baos.close(); } catch (IOException e) { e.printStackTrace(); } return bytes; }
From source file:Main.java
public static String drain(InputStream inputStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int buffer;// w w w.j a va 2 s.co m while ((buffer = inputStream.read()) >= 0) { baos.write(buffer); } return baos.toString(); }