2

The following code completely destroys the quality of the image I am capturing with my android camera. How can I compress slightly without ruining the image quality

Bundle extras = data.getExtras();
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] dataBAOS = baos.toByteArray();
M Reza
  • 18,350
  • 14
  • 66
  • 71
Louis S
  • 21
  • 4
  • 1
    It's not the compression. You're saving a thumbnail, which is what is returned on the data `Intent` for `ACTION_IMAGE_CAPTURE`. If you want the full-size image, you'll need to pass an `EXTRA_OUTPUT` extra on the `ACTION_IMAGE_CAPTURE` `Intent` to tell the camera app where to store it, since it'll be too big to pass back on an `Intent`. Have a look at CommonsWare's examples on the linked duplicates. – Mike M. May 22 '18 at 03:48
  • @MikeM Thank you so much! Where can I find that example? – Louis S May 22 '18 at 03:57
  • There are links in a banner at the top of your question now. You might need to refresh the page. Here they are again, just in case: https://stackoverflow.com/questions/45388784/picture-taken-with-camera-intent-is-low-quality-on-imageview-7-0, https://stackoverflow.com/questions/35352420/bitmap-bad-quality-after-set-to-imageview. – Mike M. May 22 '18 at 04:02

0 Answers0