This documentation is archived and is not being maintained.

ColorConvertedBitmap Class

Changes the color space of a BitmapSource.

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

public sealed class ColorConvertedBitmap : BitmapSource, 
For XAML information, see ColorConvertedBitmap Markup Extension.

ColorConvertedBitmap implements the ISupportInitialize interface to optimize initialization on multiple properties. Property changes can only occur during object initialization. Call BeginInit to signal that initialization has begun and EndInit to signal that initialization has completed. After initialization, property changes are ignored.

ColorConvertedBitmap objects created using the ColorConvertedBitmap(BitmapSource, ColorContext, ColorContext, PixelFormat) constructor are automatically initialized, and property changes are ignored.

A ColorConvertedBitmap is never cached.

The following example shows how to create an instance of ColorConvertedBitmap and use it to convert color.

Stream imageStream = new FileStream("tulipfarm.jpg", FileMode.Open, FileAccess.Read, FileShare.Read);
BitmapSource myBitmapSource = BitmapFrame.Create(imageStream);
BitmapFrame myBitmapSourceFrame = (BitmapFrame)myBitmapSource;
ColorContext sourceColorContext = myBitmapSourceFrame.ColorContexts[0];
ColorContext destColorContext = new ColorContext(PixelFormats.Bgra32);
ColorConvertedBitmap ccb = new ColorConvertedBitmap(myBitmapSource, sourceColorContext, destColorContext, PixelFormats.Pbgra32);
Image myImage3 = new Image();
myImage3.Source = ccb;
myImage3.Stretch = Stretch.None;

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0