Android bitmap to byte array without compression

How can we convert a bitmap to a byte array in Android without image compression? Image in byte array in Android:

 Bitmap photo = (Bitmap) data.getExtras().get("data");
 img_view.setImageBitmap(photo);
 Bitmap resizedImage = Bitmap.createScaledBitmap(photo,512,512 , true);
 ByteArrayOutputStream bos = new ByteArrayOutputStream(photo.getWidth()*photo.getHeight());
 resizedImage.compress(Bitmap.CompressFormat.PNG,100, bos);
 bArray = bos.toByteArray();

Set the image size from 300 to 400 kb.

+4
source share

All Articles