convert Bitmap To String - Android Graphics

Android examples for Graphics:Bitmap Save

Description

convert Bitmap To String

Demo Code


//package com.java2s;
import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;

import android.util.Base64;

public class Main {
    public static String convertBitmapToString(Bitmap bitmap) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
        byte[] byteArray = stream.toByteArray();
        String result = Base64.encodeToString(byteArray, Base64.DEFAULT);
        return result;
    }//from w  w w.  j a va 2 s.c  o  m
}

Related Tutorials