Type Default Value Read Only Static Description
Nullable<Color> null No No The GIF transparent color.

The GIF file format allows one color to be treated as transparent. You can either specify a point using TransparentPoint or a color using this property. Because the export process may re-map the colors on your Bitmap you should not specify a transparent color directly. Instead you should specify a point that will be transparent and the export process will infer the color after any color mapping has been done. The default is for no transparent colors, which is what happens when both properties are null. If both properties are not null, TransparentColor takes precedence.

See Also



Here we save a transparent gif using the color white as the transparent color.


using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/jeremy-bishop-_CFv3bntQlQ-unsplash.jpg"))) {
  Color color = Color.White;
  EncoderParameters pars = new EncoderParameters() { TransparentColor = color };
  pars.Palette = new ColorPaletteType(ColorPaletteFamily.Adaptive, 16);
  pars.Palette.FixedColors = new List<Color>(new Color[] { color });
  bm.Save(Server.MapPath("IG8_EncoderParameters_TransparentColor.gif"), ImageFormat.Gif, pars);