Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;

public class Main {
    /**
     * Compress the bitmap to a PNG and return its {@link ByteArrayInputStream}
     * 
     * @param bitmap The {@link Bitmap} to compress
     * @return The {@link ByteArrayInputStream}
     */
    public static ByteArrayInputStream toPNGInputStream(Bitmap bitmap) {
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes);
        return new ByteArrayInputStream(bytes.toByteArray());
    }
}