Makes a color transparent by setting the alpha value of all matching pixels to zero. For how to implement a fuzzy match see the AdjustColors function.
Syntax

[C#]

void MakeTransparent(Color color);

[Visual Basic]

Sub MakeTransparent(color As Color)
Params
Name Description
color The Color to make transparent.
Notes

None.

Example

[C#]using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/sam-schooler-E9aetBe2w40-unsplash.jpg"))) {
  bm.MakeTransparent(Color.White);
  using (Bitmap bm2 = new Bitmap(bm.Width, bm.Height)) {
    bm2.SetResolution(bm.VerticalResolution, bm.HorizontalResolution);
    using (Graphics gr = Graphics.FromImage(bm2)) {
      gr.Clear(Color.Green);
      gr.DrawImage(bm, bm2.Bounds);
    }
    bm2.Save(Server.MapPath("IG8_Bitmap_MakeTransparent.jpg"));
  }
}


The code here selects all the white pixels in the image and replaces them with green ones before saving the final output as a JPEG. The final output is shown below.


sam-schooler-E9aetBe2w40-unsplash.jpg


IG8_Bitmap_MakeTransparent.jpg