Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;

import android.util.Base64;

public class Main {
    public static String bmpToString(Bitmap bitmap) {
        String bmpStr = "";
        try {
            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;
    }
}