title: Making specific color in bitmap transparent
body: <p>I have an Android application to display an image on another image, such that second image's white colour is transparent. To do this, I have used two <code>ImageView</code>s, with the original image to be overlaid as <code>bitmap1</code> and the image to be made transparent as <code>bitmap2</code>. When I run this, I get some exceptions at the <code>setPixel</code> method.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>Bitmap bitmap2 = null;
  int width = imViewOverLay.getWidth();
  int height = imViewOverLay.getHeight();
  for(int x = 0; x &lt; width; x++)
  {
      for(int y = 0; y &lt; height; y++)
      {
          if(bitMap1.getPixel(x, y) == Color.WHITE)
          {
              bitmap2.setPixel(x, y, Color.TRANSPARENT);
          }
          else
          {
              bitmap2.setPixel(x, y, bitMap1.getPixel(x, y));
          }
      }
  }
  </code></pre>
  
  <p><code>imViewOverLay</code> is the <code>ImageView</code> of the overlay image. Any idea what might be going wrong in the above code?</p>