Modifica

Condividi tramite


ColorConvertedBitmap Constructors

Definition

Initializes a new instance of the ColorConvertedBitmap class.

Overloads

ColorConvertedBitmap()

Initializes a new instance of the ColorConvertedBitmap class.

ColorConvertedBitmap(BitmapSource, ColorContext, ColorContext, PixelFormat)

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

ColorConvertedBitmap()

Initializes a new instance of the ColorConvertedBitmap class.

public:
 ColorConvertedBitmap();
public ColorConvertedBitmap ();
Public Sub New ()

Remarks

ColorConvertedBitmap implements the ISupportInitialize interface to optimize initialization on multiple properties. To initialize a ColorConvertedBitmap created using this constructor, you must perform property initialization between BeginInit and EndInit calls.

Applies to

ColorConvertedBitmap(BitmapSource, ColorContext, ColorContext, PixelFormat)

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

public:
 ColorConvertedBitmap(System::Windows::Media::Imaging::BitmapSource ^ source, System::Windows::Media::ColorContext ^ sourceColorContext, System::Windows::Media::ColorContext ^ destinationColorContext, System::Windows::Media::PixelFormat format);
public ColorConvertedBitmap (System.Windows.Media.Imaging.BitmapSource source, System.Windows.Media.ColorContext sourceColorContext, System.Windows.Media.ColorContext destinationColorContext, System.Windows.Media.PixelFormat format);
new System.Windows.Media.Imaging.ColorConvertedBitmap : System.Windows.Media.Imaging.BitmapSource * System.Windows.Media.ColorContext * System.Windows.Media.ColorContext * System.Windows.Media.PixelFormat -> System.Windows.Media.Imaging.ColorConvertedBitmap
Public Sub New (source As BitmapSource, sourceColorContext As ColorContext, destinationColorContext As ColorContext, format As PixelFormat)

Parameters

source
BitmapSource

The BitmapSource that is converted.

sourceColorContext
ColorContext

The ColorContext of the source bitmap.

destinationColorContext
ColorContext

The ColorContext of the converted bitmap.

format
PixelFormat

The PixelFormat of the converted bitmap.

Examples

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();
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()

Remarks

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

See also

Applies to