Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.graphics.Bitmap;

import android.util.Base64;
import android.util.Log;
import java.io.ByteArrayOutputStream;

public class Main {
    public static String getImageAsString(Bitmap bmp) {
        ByteArrayOutputStream bYtE = new ByteArrayOutputStream();

        bmp.compress(Bitmap.CompressFormat.JPEG, 100, bYtE);
        byte[] byteArray = bYtE.toByteArray();
        String image = Base64.encodeToString(byteArray, Base64.DEFAULT);
        bmp.recycle();
        Log.d("Converted TO : ", image);
        return image;
    }
}