Convert bitmap to Byte array - Android Graphics

Android examples for Graphics:Bitmap Byte Array

Description

Convert bitmap to Byte array

Demo Code


//package com.java2s;

import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;

public class Main {

    public static byte[] bitmap2Bytes(Bitmap bm) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
        return baos.toByteArray();
    }/*from  w w  w  . jav a  2 s  . co  m*/
}

Related Tutorials