Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Bitmap;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class Main {
    /**
     * TODO doc
     *
     * @param photoBitmap
     * @return
     */
    public static byte[] toByteArray(Bitmap photoBitmap) throws IOException {
        ByteArrayOutputStream blob = new ByteArrayOutputStream();
        photoBitmap.compress(Bitmap.CompressFormat.PNG, 0 /*ignored for PNG*/, blob);
        byte[] photoByteArray = blob.toByteArray();
        blob.close();
        return photoByteArray;
    }
}