title: Image mask by another image or color using c#
body: <p>I looking for solution just like in the above question just in c#</p>
  
  <p><a href="https://stackoverflow.com/questions/17835435/how-to-draw-on-bitmap-using-another-bitmap-as-mask">question about android</a></p>
  
  <p>I know how to do this with color, but I need to do this with image too.</p>
  
  <p>Here is my code for color replacement:</p>
  
  <pre><code>Bitmap bit = new Bitmap(img);
  for (int y = 0; y &lt; img.Height; y++)
  {
      for (int x = 0; x &lt; img.Width; x++)
      {
         if (bit.GetPixel(x, y).A != 0)
         {
            bit.SetPixel(x, y, Color.Red);
         }
      }
  }
  bit.Save(stream, ImageFormat.Png);
  </code></pre>