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 java.nio.ByteBuffer;

public class Main {
    public static String convertBitmapToBase64(Bitmap bitmap) {
        final int size = bitmap.getByteCount();

        ByteBuffer dst = ByteBuffer.allocate(size);
        bitmap.copyPixelsToBuffer(dst);
        return Base64.encodeToString(dst.array(), Base64.DEFAULT);
    }
}