Swap Channels

View as Markdown

BitmapChannels

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

Code 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

Chicago.jpg

Output

SwapChannels.jpg

SwapChannels.jpg

Used APIs