title: Why the color of the image changed when it compressed by Bitmap.CompressFormat.JPEG
body: <p>I am trying to compress the photo took by the camera in Android. But the color of the image changed when it compressed by Bitmap.CompressFormat.JPEG. How can I solve this problem? Thanks</p>
  
  <p>I have put some sample images which generated from my code. You can see the color of the paper on the top of the images is different.</p>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>Bitmap bitmap = BitmapFactory.decodeFile(Common.FOLDER_PATH + "pic.jpg");
  
  FileOutputStream stream2 = new FileOutputStream(Common.FOLDER_PATH + "pic100.jpg");         
  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream2); 
  
  FileOutputStream stream3 = new FileOutputStream(Common.FOLDER_PATH + "pic100.png");         
  bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream3);
  </code></pre>
  
  <p>This is original image:
  <img src="https://i.stack.imgur.com/4U2eh.jpg" alt="original">
  <br>This is JPEG:
  <img src="https://i.stack.imgur.com/a4vmg.jpg" alt="jpg">
  <br>This is PNG:
  <img src="https://i.stack.imgur.com/SDU1D.jpg" alt="png"></p>