Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; public class Main { /** * Convert a Bitmap into a byte Array * @param bitmap * @return */ public static byte[] convertBitmapToByte(Bitmap bitmap) { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray(); return byteArray; } catch (Exception e) { return null; } } }