Java tutorial
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import android.graphics.Bitmap; public class Main { public static InputStream Bitmap2InputStream(Bitmap bm, int quality) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, quality, baos); InputStream is = new ByteArrayInputStream(baos.toByteArray()); return is; } }