Namespace:
System.Windows.Media.Imaging
Assembly:
PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Visual Basic (Declaration)
Public NotInheritable Class ColorConvertedBitmap _
Inherits BitmapSource _
Implements ISupportInitialize
Dim instance As ColorConvertedBitmap
public sealed class ColorConvertedBitmap : BitmapSource,
ISupportInitialize
public ref class ColorConvertedBitmap sealed : public BitmapSource,
ISupportInitialize
public final class ColorConvertedBitmap extends BitmapSource implements ISupportInitialize
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.
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()
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;
imageStream.Close();
System..::.Object
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
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
Reference
Other Resources