Example usage for android.util Base64 DEFAULT

List of usage examples for android.util Base64 DEFAULT

Introduction

In this page you can find the example usage for android.util Base64 DEFAULT.

Prototype

int DEFAULT

To view the source code for android.util Base64 DEFAULT.

Click Source Link

Document

Default values for encoder/decoder flags.

Usage

From source file:Main.java

public static String getBase64FromBitmap(Bitmap bitmap, int bitmapQuality) {
    ByteArrayOutputStream bStream = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.PNG, bitmapQuality, bStream);
    byte[] bytes = bStream.toByteArray();
    return Base64.encodeToString(bytes, Base64.DEFAULT);
}

From source file:Main.java

public static String bitmaptoString(Bitmap bitmap) {
    String string = null;//from ww  w.  ja v a  2 s  .  c  o m
    ByteArrayOutputStream bStream = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.PNG, 50, bStream);
    byte[] bytes = bStream.toByteArray();
    string = Base64.encodeToString(bytes, Base64.DEFAULT);
    return string;
}

From source file:Main.java

public static String bmpToString(Bitmap bitmap) {
    String bmpStr = "";
    try {/*from  w ww. j  a  va  2s.co  m*/
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
        byte[] bts = outputStream.toByteArray();
        bmpStr = Base64.encodeToString(bts, Base64.DEFAULT);
    } catch (Exception e) {
        // TODO: handle exception
    }
    return bmpStr;
}

From source file:Main.java

public static String encodeToBase64(Bitmap image) {
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    image.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
    byte[] bytes = byteArrayOutputStream.toByteArray();
    return Base64.encodeToString(bytes, Base64.DEFAULT);
}

From source file:Main.java

public static String encodeTobase64(Bitmap image) {
    Bitmap immagex = image;//from   ww w  . j  a  va 2s  .co  m
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] b = baos.toByteArray();
    String imageEncoded = Base64.encodeToString(b, Base64.DEFAULT);
    return imageEncoded;
}

From source file:Main.java

/**
 * convert (encode) image to string//from w  ww  .  ja va 2 s.com
 * **/
public static String encodeToBase64(Bitmap image, Bitmap.CompressFormat compressFormat, int quality) {
    ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
    image.compress(compressFormat, quality, byteArrayOS);
    return Base64.encodeToString(byteArrayOS.toByteArray(), Base64.DEFAULT);
}

From source file:Main.java

public static String bitmapToBase64(Bitmap bitmap) {

    try {//from w  w w.j  av a2 s . c  om
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        baos.close();
        byte[] buffer = baos.toByteArray();
        String photo = Base64.encodeToString(buffer, 0, buffer.length, Base64.DEFAULT);
        return photo;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static byte[] convertBase64IntoByte(String base64) {
    byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
    return decodedString;
}

From source file:Main.java

public static String Base64Pic(String path) throws Exception {
    Bitmap bm = getSmallBitmap(path, 300, 300);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] b = baos.toByteArray();
    return Base64.encodeToString(b, Base64.DEFAULT);
}

From source file:Main.java

/**
 * generate base64 from bitmap image//w  w  w . j av  a 2 s.c  o m
 * @param mBitmap bitmap image
 * @return base64 string
 */
public static String ImageToBase64(Bitmap mBitmap) {
    ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
    mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos1);
    byte[] b1 = baos1.toByteArray();
    return Base64.encodeToString(b1, Base64.DEFAULT);
}