Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import java.io.ByteArrayOutputStream; public class Main { public static byte[] convertToBytes(Bitmap bitmap, CompressFormat format, int quality) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(format, quality, stream); byte[] data = stream.toByteArray(); try { stream.close(); } catch (Exception e) { // nothing } return data; } }