Example usage for java.io ByteArrayOutputStream ByteArrayOutputStream

List of usage examples for java.io ByteArrayOutputStream ByteArrayOutputStream

Introduction

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

Prototype

public ByteArrayOutputStream() 

Source Link

Document

Creates a new ByteArrayOutputStream .

Usage

From source file:Main.java

public static byte[] bitmapToBytes(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) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 200, stream);
    return stream.toByteArray();
}

From source file:Main.java

public static byte[] removeBy(int value, byte[] content) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    if (content.length > 0) {
        boolean preisSame = true; //
        int tailIndex = content.length - 1;
        for (int i = 0; i < content.length; i++) {
            if (content[i] != value) {
                preisSame = false;//from w  ww  . j a v  a 2  s .  c o  m
                out.write(content[i]);
            } else if (content[i] == value && preisSame) {
                //ignore
            } else if (i == tailIndex) {

            } else {
                out.write(value);
                preisSame = true;
            }
        }

    }
    return out.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[] bitmap2Bytes(Bitmap bitmap) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    return baos.toByteArray();
}

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 byte[] bitmapToByte(Bitmap bitmap) {

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    byte[] yy = baos.toByteArray();
    return yy;// w w w.ja  v  a  2 s  . c  o m
}

From source file:Main.java

public static byte[] concatByteArrays(byte[] a, byte[] b) {
    try {//w  w  w.j a v  a  2  s  . com
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        outputStream.write(a);
        outputStream.write(b);
        return outputStream.toByteArray();
    } catch (Exception e) {
        return null;
    }
}

From source file:Main.java

public static byte[] toByteArray(Bitmap bitmap) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
    return outputStream.toByteArray();
}

From source file:Main.java

public static byte[] getByteArrayFromBitmap(Bitmap map) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    map.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    return baos.toByteArray();
}