title: Convert white color to transparent on bitmap in android
body: <p>I want to convert white background to transparent background in android bitmap.</p>
  
  <p>My situation:</p>
  
  <p>Original Image : I cannot post a image</p>
  
  <pre><code>public Bitmap replaceColor(Bitmap src){
      if(src == null)
          return null;
      int width = src.getWidth();
      int height = src.getHeight();
      int[] pixels = new int[width * height];
      src.getPixels(pixels, 0, width, 0, 0, width, height);
      for(int x = 0;x &lt; pixels.length;++x){
          pixels[x] = ~(pixels[x] &lt;&lt; 8 &amp; 0xFF000000) &amp; Color.BLACK;
      }
      Bitmap result = Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
      return result;
      }
  </code></pre>
  
  <p>Processing After
  It was detect pixel to pixel, one by one.
  It's good but this bitmap image doesn't remain original color.</p>
  
  <p>So, I append code to filter.</p>
  
  <pre><code>if (pixels[x] == Color.white)
  
      public Bitmap replaceColor(Bitmap src){
      if(src == null)
          return null;
      int width = src.getWidth();
      int height = src.getHeight();
      int[] pixels = new int[width * height];
      src.getPixels(pixels, 0, width, 0, 0, width, height);
      for(int x = 0;x &lt; pixels.length;++x){
          if(pixels[x] == Color.WHITE){
            pixels[x] = ~(pixels[x] &lt;&lt; 8 &amp; 0xFF000000) &amp; Color.BLACK;
          }   
      }
      Bitmap result = Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
      return result;
      }
  </code></pre>
  
  <p>Processing After,</p>
  
  <p>But, this picture can not remove completely color white.
  So, It is not pretty. </p>
  
  <p>I really want remove white background in android bitmap</p>
  
  <p>My code is following in under stackoverflow article.</p>
  
  <p><a href="https://stackoverflow.com/questions/6432965/android-bitmap-mask-color-remove-color">Android bitmap mask color, remove color</a></p>