Example usage for java.io ByteArrayOutputStream toByteArray

List of usage examples for java.io ByteArrayOutputStream toByteArray

Introduction

In this page you can find the example usage for java.io ByteArrayOutputStream toByteArray.

Prototype

public synchronized byte[] toByteArray() 

Source Link

Document

Creates a newly allocated byte array.

Usage

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);/* w  ww .  ja  v  a2s  .co  m*/

    byte[] array = os.toByteArray();
    return BitmapFactory.decodeByteArray(array, 0, array.length);
}

From source file:Main.java

/**
 * convert Bitmap to byte array/*ww  w . ja v a  2s. c o  m*/
 */
public static byte[] bitmapToByte(Bitmap b) {
    ByteArrayOutputStream o = new ByteArrayOutputStream();
    b.compress(Bitmap.CompressFormat.PNG, 100, o);
    return o.toByteArray();
}

From source file:Main.java

/**
 * Decodes a bitmap to its corresponding representation in bytes, in the format sent as parameter
 *
 * @param bitmap Bitmap to decode/*  ww  w.  j ava  2  s  .c o m*/
 * @param format Format with which this image is going to be decoded
 * @return A byte array containing the bytes of the decoded bitmap
 */
public static byte[] bitmapToByteArray(Bitmap bitmap, Bitmap.CompressFormat format) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(format, 100, stream);
    return stream.toByteArray();
}

From source file:Main.java

public static byte[] bitmapToByteArray(Bitmap b) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    b.compress(Bitmap.CompressFormat.PNG, 100, bos);
    return bos.toByteArray();
}

From source file:Main.java

public static byte[] getBytes(Bitmap bitmap) {
    ByteArrayOutputStream baops = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.PNG, 0, baops);
    return baops.toByteArray();
}

From source file:Main.java

private static Bitmap compassBitmap(Bitmap src, Bitmap.CompressFormat format, int quality) {

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    src.compress(format, quality, os);/*from   www. j  a  v a2s.c o  m*/

    byte[] array = os.toByteArray();
    return BitmapFactory.decodeByteArray(array, 0, array.length);
}

From source file:Main.java

public static byte[] BitmapToBytes(Bitmap bm) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
    return baos.toByteArray();
}

From source file:Main.java

public static byte[] getBytes(Bitmap bitmap) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.PNG, 0, stream);
    return stream.toByteArray();
}

From source file:Main.java

public static byte[] convertBitmap2Bytes(Bitmap bm) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
    return baos.toByteArray();
}

From source file:Main.java

public static byte[] bitmap2Bytes(Bitmap bm) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
    return baos.toByteArray();
}