Monday, 18 June 2012

Convert Bitmap into ByteArray

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.abstrakt);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();


Don’t forget to provide feedback or follow this blog, if you find this blog is useful.

1 comment:

  1. if image is of 2 mb and above then this code throws out of memory error.