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