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;

public class Main {
    /**
     * @brief      Converting bitmap to bytes array.
     * 
     * @param      bm   [IN]  bitmap object
     * 
     * @return     Return converted bytes array
     */
    public static byte[] bitmapToBytes(Bitmap bm) {
        if (bm == null) {
            return null;
        }

        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.PNG, 100, os);
        return os.toByteArray();
    }
}