ColorConvertedBitmap Constructor (BitmapSource, ColorContext, ColorContext, PixelFormat)

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
)

Parameters

source
Type: System.Windows.Media.Imaging.BitmapSource

The BitmapSource that is converted.

sourceColorContext
Type: System.Windows.Media.ColorContext

The ColorContext of the source bitmap.

destinationColorContext
Type: System.Windows.Media.ColorContext

The ColorContext of the converted bitmap.

format
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;
imageStream.Close();

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