title: How convert Bitmap to byte array and back without quality reduction?
body: <p>When I convert a picture into bytes and back, the quality deteriorates a lot. How to do it without reducing quality?</p>
  
  <p>I need to save the photo in the database or send it to the server. I can consider other options to do this.</p>
  
  <pre><code>public static byte[] fromBitmap(Bitmap bitmap) {
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
      return stream.toByteArray();
  }
  public static Bitmap toBitmap(byte[] bytes) {
      return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
  }
  </code></pre>