andreluizreis
7/11/2017 - 4:52 PM

Get file from Drawable. Bitmap to byte[].

Get file from Drawable. Bitmap to byte[].

/**
 * Get file from Drawable
 * @param bitmap bitmap image
 * @return byte array
 */
private byte[] getFileDataFromDrawable(Bitmap bitmap) {
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 0, byteArrayOutputStream);
    return byteArrayOutputStream.toByteArray();
}