---
title: "Add Alpha Channel"
canonical: https://www.graphicsmill.com/samples/ColorManagement/Channels/AddAlphaChannel_cs
product: "Graphics Mill"
source: "ColorManagement/Channels/AddAlphaChannel.cs"
---

# Add Alpha Channel

Generates an elliptical alpha channel and applies it to the source image.

## Instruction

Adds an alpha channel to an image by creating a grayscale bitmap and setting it as the alpha channel.

## Usings

```csharp
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
using (var bitmap = new Bitmap("Chicago.jpg"))
using (var alpha = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format8bppGrayscale, new GrayscaleColor(0)))
using (var graphics = alpha.GetGraphics())
{
    graphics.FillEllipse(
        new SolidBrush(new GrayscaleColor(255)),
        0,
        0,
        bitmap.Width,
        bitmap.Height);

    bitmap.Channels.SetAlpha(alpha);

    bitmap.Save("AddAlphaChannel.png");
}
```

## Explanation

The following code:

- Loads the image from the file `Chicago.jpg`.
- Creates a grayscale `alpha` bitmap with a fully transparent alpha channel.
- Draws a filled ellipse with full opacity onto the `alpha` bitmap.
- Sets the `alpha` bitmap as the alpha channel of the original image.
- Saves the resulting image as a PNG file `AddAlphaChannel.png`.

## Tags

- [Bitmap](<https://www.graphicsmill.com/samples/tags/bitmap_md>): Working with images via the Bitmap API
- [Channels](<https://www.graphicsmill.com/samples/tags/channels_md>): Reading and combining image channels
- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text

## Input

- [Chicago.jpg](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/Chicago_jpg>) (preview)

## Output

- [AddAlphaChannel.png](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/AddAlphaChannel_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.Channels](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Bitmap_Channels.htm.md>)
- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.ChannelsProvider.SetAlpha(Bitmap)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_ChannelsProvider_SetAlpha_1_fd4033ef.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.FillEllipse(Brush,Single,Single,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_FillEllipse_5_2d30ad96.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.GrayscaleColor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_GrayscaleColor.htm.md>)
