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 bitmapChangeString(Bitmap bitmap) {
        if (bitmap != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
            String str = new String(Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT));
            return str;
        }
        return null;
    }
}