bitmap to String - Android Graphics

Android examples for Graphics:Bitmap String

Description

bitmap to String

Demo Code


//package com.java2s;

import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;

import android.util.Base64;

public class Main {
    public static String bitmaptoString(Bitmap bitmap) {

        String string = null;//w ww  . j  a v a2  s  .c  om
        ByteArrayOutputStream bStream = new ByteArrayOutputStream();
        bitmap.compress(CompressFormat.PNG, 100, bStream);
        byte[] bytes = bStream.toByteArray();
        string = Base64.encodeToString(bytes, Base64.DEFAULT);
        return string;
    }
}

Related Tutorials