Example usage for android.graphics Bitmap compress

List of usage examples for android.graphics Bitmap compress

Introduction

In this page you can find the example usage for android.graphics Bitmap compress.

Prototype

@WorkerThread
public boolean compress(CompressFormat format, int quality, OutputStream stream) 

Source Link

Document

Write a compressed version of the bitmap to the specified outputstream.

Usage

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();
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static ByteArrayInputStream Bitmap2InputStream(Bitmap bm) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    ByteArrayInputStream is = new ByteArrayInputStream(baos.toByteArray());
    return is;/*w  w  w .j av  a2 s  . c  om*/
}

From source file:Main.java

public static String bitmapToBase64(Bitmap bm) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm is the bitmap object   
    byte[] b = baos.toByteArray();
    return Base64.encodeToString(b, Base64.DEFAULT);
}

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

From source file:Main.java

public static byte[] getBitmapData(Bitmap photo) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    photo.compress(Bitmap.CompressFormat.JPEG, 70, baos);
    return baos.toByteArray();
}

From source file:Main.java

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

From source file:Main.java

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