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 bitmapToString(Bitmap bitmap) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] b = baos.toByteArray();
    return Base64.encodeToString(b, Base64.DEFAULT);
}

From source file:Main.java

public static String BitmapToBase64PNG(Bitmap bmp) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.JPEG, 40, baos);
    byte[] data = baos.toByteArray();
    return Base64.encodeToString(data, Base64.DEFAULT);
}

From source file:Main.java

public static final String bitMapToString(Bitmap bitmap) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    byte[] b = baos.toByteArray();
    String temp = Base64.encodeToString(b, Base64.DEFAULT);
    return temp;/*  w  ww  .j a v a2  s.co m*/
}

From source file:Main.java

public static String BitMapToString(Bitmap bitmap) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    byte[] arr = baos.toByteArray();
    String result = Base64.encodeToString(arr, Base64.DEFAULT);
    return result;
}

From source file:Main.java

public static String bitmapToString(Bitmap bitmap) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    byte[] arr = baos.toByteArray();
    String result = Base64.encodeToString(arr, Base64.DEFAULT);
    return result;
}

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 String BitmapToBase64(Bitmap bitmap) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] imageBytes = baos.toByteArray();
    return Base64.encodeToString(imageBytes, Base64.DEFAULT);
}

From source file:Main.java

public static Bitmap convertStringToBitmap(String st) {
    // OutputStream out;
    Bitmap bitmap = null;//from  www .  j a va2 s.co m
    try {
        // out = new FileOutputStream("/sdcard/aa.jpg");
        byte[] bitmapArray;
        bitmapArray = Base64.decode(st, Base64.DEFAULT);
        bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
        // bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
        return bitmap;
    } catch (Exception e) {
        return null;
    }
}

From source file:Main.java

static void setBasicAuthentication(HttpURLConnection conn, URL url) {
    String userInfo = url.getUserInfo();
    if (userInfo != null && userInfo.length() > 0) {
        String authString = Base64.encodeToString(userInfo.getBytes(), Base64.DEFAULT);
        conn.setRequestProperty("Authorization", "Basic " + authString);
    }// w  w  w. j  a v a2  s.  c o m
}

From source file:Main.java

public static String encodeToJPEGbase64(Bitmap image) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] b = baos.toByteArray();
    String imageEncoded = Base64.encodeToString(b, Base64.DEFAULT);
    return imageEncoded;
}