ColorConvertedBitmap Constructor (BitmapSource, ColorContext, ColorContext, PixelFormat)
Collapse the table of content
Expand the table of content

ColorConvertedBitmap Constructor (BitmapSource, ColorContext, ColorContext, PixelFormat)


Initializes a new instance of the ColorConvertedBitmap class by using the specified values.

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

public ColorConvertedBitmap(
	BitmapSource source,
	ColorContext sourceColorContext,
	ColorContext destinationColorContext,
	PixelFormat format


Type: System.Windows.Media.Imaging.BitmapSource

The BitmapSource that is converted.

Type: System.Windows.Media.ColorContext

The ColorContext of the source bitmap.

Type: System.Windows.Media.ColorContext

The ColorContext of the converted bitmap.

Type: System.Windows.Media.PixelFormat

The PixelFormat of the converted bitmap.

ColorConvertedBitmap objects created using this constructor are automatically initialized. After initialization, property changes are ignored.

The following example shows how to initialize an instance of ColorConvertedBitmap by using the ColorConvertedBitmap(BitmapSource, ColorContext, ColorContext, PixelFormat) constructor.

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;

.NET Framework
Available since 3.0
Return to top
© 2016 Microsoft