Bitmap to InputStream - Android Graphics

Android examples for Graphics:Bitmap Stream

Description

Bitmap to InputStream

Demo Code


//package com.java2s;

import android.graphics.Bitmap;

import java.io.*;

public class Main {
    public static InputStream Bitmap2InputStream(Bitmap bm) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        InputStream is = new ByteArrayInputStream(baos.toByteArray());
        return is;
    }// w  ww  . j  av  a2s .co m
}

Related Tutorials