Java tutorial
//package com.java2s; import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; public class Main { /** * bitmap -> bytes * * */ public static byte[] bitmap2Bytes(Bitmap bitmap) { if (null == bitmap) { return null; } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); return byteArrayOutputStream.toByteArray(); } }