ColorConvertedBitmap Class
Changes the color space of a BitmapSource.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
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.
Dim imageStream As New FileStream("tulipfarm.jpg", FileMode.Open, FileAccess.Read, FileShare.Read) Dim myBitmapSource As BitmapSource = BitmapFrame.Create(imageStream) Dim myBitmapSourceFrame As BitmapFrame = CType(myBitmapSource, BitmapFrame) Dim sourceColorContext As ColorContext = myBitmapSourceFrame.ColorContexts(0) Dim destColorContext As New ColorContext(PixelFormats.Bgra32) Dim ccb As New ColorConvertedBitmap(myBitmapSource, sourceColorContext, destColorContext, PixelFormats.Pbgra32) Dim myImage3 As New Image() myImage3.Source = ccb myImage3.Stretch = Stretch.None imageStream.Close()
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Freezable
System.Windows.Media.Animation.Animatable
System.Windows.Media.ImageSource
System.Windows.Media.Imaging.BitmapSource
System.Windows.Media.Imaging.ColorConvertedBitmap
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.