get Byte array From Bitmap - Android android.graphics

Android examples for android.graphics:Bitmap Load Save

Description

get Byte array From Bitmap

Demo Code

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;
import android.util.Log;
import java.io.ByteArrayOutputStream;

public class Main{

    public static final byte[] getBytesFromBitmap(Bitmap bitmap) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
        bitmap.recycle();//from w  w  w.  ja  v  a  2  s .  c  om

        return stream.toByteArray();
    }

}

Related Tutorials