Here you can find the source of bitmap2Stream(Bitmap bitmap)
public static final InputStream bitmap2Stream(Bitmap bitmap)
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; public class Main { public static final InputStream bitmap2Stream(Bitmap bitmap) { return bitmap2Stream(bitmap, CompressFormat.JPEG, 100); }//w w w.ja v a2 s .c o m public static final InputStream bitmap2Stream(Bitmap bitmap, CompressFormat format, int quality) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(format, quality, baos); InputStream stream = new ByteArrayInputStream(baos.toByteArray()); return stream; } }