List of usage examples for java.io ByteArrayOutputStream toByteArray
public synchronized byte[] toByteArray()
From source file:Main.java
public static byte[] Bitmap2Bytes(Bitmap bm, Bitmap.CompressFormat format) { if (bm == null) { return null; }/* w ww . j ava 2 s .c o m*/ ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(format, 100, baos); return baos.toByteArray(); }
From source file:Main.java
public static byte[] serializerBytes(Object xmlObj) throws JAXBException { JAXBContext context = JAXBContext.newInstance(xmlObj.getClass()); Marshaller marshaller = context.createMarshaller(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); marshaller.marshal(xmlObj, baos);//from w ww .j a va 2s . co m return baos.toByteArray(); }
From source file:Main.java
public static byte[] bitmapToByte(Bitmap bitmap, Bitmap.CompressFormat fmt) { if (bitmap == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(fmt, 100, baos);/*from w w w. j a v a 2 s. co m*/ return baos.toByteArray(); }
From source file:Main.java
public static byte[] bitmapToByteArray(Bitmap b) { ByteArrayOutputStream bs = new ByteArrayOutputStream(); b.compress(Bitmap.CompressFormat.PNG, 50, bs); return bs.toByteArray(); }
From source file:Main.java
public static byte[] bitmap2Bytes(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(CompressFormat.PNG, 100, baos); return baos.toByteArray(); }
From source file:Main.java
public static byte[] Bitmap2Bytes(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(CompressFormat.JPEG, 100, baos); return baos.toByteArray(); }
From source file:Main.java
public static byte[] compress(Bitmap bitmap, int quality, Bitmap.CompressFormat format) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(format, quality, baos); return baos.toByteArray(); }
From source file:Main.java
public static Bitmap codec(Bitmap src, Bitmap.CompressFormat format, int quality) { ByteArrayOutputStream os = new ByteArrayOutputStream(); src.compress(format, quality, os);//ww w. j a v a2s. co m byte[] array = os.toByteArray(); return BitmapFactory.decodeByteArray(array, 0, array.length); }
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 byte[] Bitmap2Bytes(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(CompressFormat.PNG, 100, baos); return baos.toByteArray(); }