Android Bitmap to Byte Array Convert getBytes(Bitmap bm)

Here you can find the source of getBytes(Bitmap bm)

Description

get Bytes

Declaration

public static byte[] getBytes(Bitmap bm) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import java.io.ByteArrayOutputStream;

public class Main {
    public static byte[] getBytes(Bitmap bm) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
        byte[] byteArray = stream.toByteArray();

        return byteArray;
    }//  www .j a v a 2  s.c  om
}

Related

  1. getByteArrayFromImageUri(Activity ctx, Uri uri)
  2. bitmap2Bytes(Bitmap bitmap, Bitmap.CompressFormat mCompressFormat, final boolean needRecycle)
  3. bitmap2Bytes(Bitmap bm)
  4. bmpToByteArray(final Bitmap bmp, final boolean needRecycle)
  5. convertBitmapToByte(Bitmap shopbitmap)
  6. getByteCount(Bitmap bitmap, Bitmap.CompressFormat mCompressFormat)