---
title: "Swap Channels"
canonical: https://www.graphicsmill.com/samples/ColorManagement/Channels/SwapChannels_cs
product: "Graphics Mill"
source: "ColorManagement/Channels/SwapChannels.cs"
---

# Swap Channels

Demonstrates how to swap color channels of an image (in this case, blue and green channels).

## Instruction

Demonstrates how to swap color channels of an image (in this case, blue and green channels).

## Code Snippet

```csharp
using (var bitmap = new Bitmap("Chicago.jpg"))
{
    // http://www.graphicsmill.com/docs/gm/accessing-pixel-data.htm
    // Format24bppRgb - [Blue] = 0|[Green] = 1|[Red] = 2
    // Swap blue (0) and green (1) channels
    bitmap.Channels.SwapChannels(new int[] { 1, 0, 2 });

    bitmap.Save("SwapChannels.jpg");
}
```

## Explanation

The following code:

- Reads the image (`Chicago.jpg`) into a `Bitmap` object.
- Swaps the blue and green channels using `SwapChannels` method.
- Saves the modified image as `SwapChannels.jpg` with the blue and green channels swapped.

## 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

## Input

- [Chicago.jpg](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/Chicago_jpg>) (preview)

## Output

- [SwapChannels.jpg](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/SwapChannels_jpg>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.Channels](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Bitmap_Channels.htm.md>)
- [Aurigma.GraphicsMill.ChannelsProvider.SwapChannels(Int32\[\])](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_ChannelsProvider_SwapChannels_1_a56295c4.htm.md>)
