Swap Channels

Channels Bitmap

Demonstrates how to swap color channels of an image (in this case, blue and green channels).

Сode Snippet

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");
}

Input

Chicago.jpg

Output

SwapChannels.jpg

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog