You would need to get the Bitmap from the URI.
Pseduo:
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage);
And then to get the byte[] you can do:
private byte[] toByteArray(@NonNull Bitmap bm)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG,100,baos);
return baos.toByteArray();
}
But do take care as these could Out Of Memory error with large files. Even base64Encoding these into a String can cause OOM.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…