Java tutorial
//package com.java2s; //License from project: Apache License 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 InputStream bitmap2Ins(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(CompressFormat.JPEG, 100, baos); InputStream sbs = new ByteArrayInputStream(baos.toByteArray()); return sbs; } }