Java tutorial
//package com.java2s; //License from project: Creative Commons License import java.io.ByteArrayOutputStream; import java.io.IOException; import android.graphics.Bitmap; public class Main { public static byte[] convertToByteArray(Bitmap bmp) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 80, stream); byte[] byteArray = stream.toByteArray(); try { stream.close(); } catch (IOException e) { e.printStackTrace(); } return byteArray; } }