title: Bitmap color change while compressing to png
body: <p>I'm currently working on a steganogrpahy android app as a class project. I've created an object that will encode an image with in another image and return an encoded bitmap. This code is run in a seprate thread. </p>
  
  <pre><code>new Thread(new Runnable()  
  {  
     public void run()  
      {  
          Bitmap encoded_image = null;  
          Encryptor encryptor = new Encryptor();  
          encoded_image = encryptor.encode_image_in_image(  
              image_location,message_image_location);  
      }  
  }).start();
  </code></pre>
  
  <p>After encoding the bitmap I was passing the bitmap to a file browser activity that I've created to save the bitmap as a png image. This method works for smaller images however, when a large image is encoded and passed to the sub activity the application freezes and returns to the main activity.</p>
  
  <pre><code>private void pass_image_to_file_browser( Bitmap image )
  {
      Intent intent = new Intent(Encrypt.this,FileBrowser.class);
      intent.putExtra( Intent.EXTRA_STREAM, image );
      startActivity( intent );
  }
  
  @Override
   public void onCreate(Bundle savedInstanceState) 
   {
      super.onCreate(savedInstanceState);
      Bundle bundle = this.getIntent().getExtras();
      Bitmap image = bundle.getParacable(Intent.EXTRA_STREAM);
   }
  </code></pre>
  
  <p>I  was assuming a large bitmap was to large to send between activities using an intent so I decided to simply save the image in a temporary location and pass the image's location to the sub activity. Which then saves the png image where the user specifies and deletes the temporary image file. </p>
  
  <pre><code>private void save_bitmap( Bitmap image, String location )
  {
      FileOutputStream fileOutputStream = new FileOutputStream(location);
      BufferedOutputStream buffered_output_stream = new 
          BufferOutputStream(fileOutputStream);
      image.compress(CompressFormat.PNG, 0, buffered_output_stream);
      buffered_output_stream.flush();
      buffered_output_stream.close();
  }
  </code></pre>
  
  <p>This solves the problem of sending a large bitmap from one activity to another however, has created a new problem that I haven't been able to solve. Both the temporary image that is saved before passing the file location to the sub activity and the image file after re saving the image using the file browser have both had their color changed slightly. This color change is unrecognizable to the naked eye but, when decoding the image it causes lots of problems.
  One thought I had was that the Bitmap.Config was changing from ARGB_8888 to ARGB_4444 or RGB_565 however, after debug this is not the case. The bitmap is instantiated as an ARGB_8888 and saved as an ARGB_8888 bitmap and never changes in between. The code still works if I pass the entire bitmap to the file browser activity and I'm saving the bitmaps exactly the same in both places. I do not have any thoughts on what else could be causing this. I'm looking for suggestions on what else could be causing the problem. Sorry I was going to post images on the output in both cases however, stack overflow wouldn't let me at my reputation level Thanks.</p>