ColorConvertedBitmap 類別

定義

變更 BitmapSource 的色彩空間。

public ref class ColorConvertedBitmap sealed : System::Windows::Media::Imaging::BitmapSource, System::ComponentModel::ISupportInitialize
public sealed class ColorConvertedBitmap : System.Windows.Media.Imaging.BitmapSource, System.ComponentModel.ISupportInitialize
type ColorConvertedBitmap = class
    inherit BitmapSource
    interface ISupportInitialize
Public NotInheritable Class ColorConvertedBitmap
Inherits BitmapSource
Implements ISupportInitialize
繼承
實作

範例

下列範例示範如何建立 的 ColorConvertedBitmap 實例,並使用它來轉換色彩。

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

備註

如需 XAML 使用方式資訊,請參閱 ColorConvertedBitmap 標記延伸

ColorConvertedBitmap 會實作 ISupportInitialize 介面,以優化多個屬性上的初始化。 只有在物件初始化期間,才會發生屬性變更。 呼叫 BeginInit 以表示初始化已開始,並 EndInit 表示初始化已完成。 初始化之後,會忽略屬性變更。

ColorConvertedBitmap 使用建構函式建立的物件 ColorConvertedBitmap(BitmapSource, ColorContext, ColorContext, PixelFormat) 會自動初始化,並忽略屬性變更。

ColorConvertedBitmap永遠不會快取 。

建構函式

ColorConvertedBitmap()

初始化 ColorConvertedBitmap 類別的新執行個體。

ColorConvertedBitmap(BitmapSource, ColorContext, ColorContext, PixelFormat)

使用指定的值,初始化 ColorConvertedBitmap 類別的新執行個體。

欄位

DestinationColorContextProperty

識別 DestinationColorContext 相依性屬性。

DestinationFormatProperty

識別 DestinationFormat 相依性屬性。

SourceColorContextProperty

識別 SourceColorContext 相依性屬性。

SourceProperty

識別 Source 相依性屬性。

屬性

CanFreeze

取得值,指出是否可以將物件設為不可修改。

(繼承來源 Freezable)
DependencyObjectType

DependencyObjectType取得包裝這個實例之 CLR 型別的 。

(繼承來源 DependencyObject)
DestinationColorContext

取得或設定值,這個值會識別已轉換之點陣圖的色彩設定檔 (由 ColorContext 類別所定義)。

DestinationFormat

取得或設定值,這個值表示已轉換之點陣圖的 PixelFormat

Dispatcher

取得與這個 Dispatcher 關聯的 DispatcherObject

(繼承來源 DispatcherObject)
DpiX

取得影像 (DPI) 的水準點。

(繼承來源 BitmapSource)
DpiY

取得影像 (DPI) 的垂直點。

(繼承來源 BitmapSource)
Format

取得點陣圖資料的原生 PixelFormat

(繼承來源 BitmapSource)
HasAnimatedProperties

取得值,這個值表示是否有一個或多個 AnimationClock 物件與這個物件的任何一個相依性屬性相關聯。

(繼承來源 Animatable)
Height

取得裝置獨立單位中來源點陣圖的高度 (,每單位 1/96 英吋) 1/96 英吋。

(繼承來源 BitmapSource)
IsDownloading

取得值,這個值表示目前是否正在下載 BitmapSource 內容。

(繼承來源 BitmapSource)
IsFrozen

取得值,該值表示物件目前是否可修改。

(繼承來源 Freezable)
IsSealed

取得值,這個值表示此執行個體目前是否已密封 (唯讀)。

(繼承來源 DependencyObject)
Metadata

取得與這個點陣圖影像相關聯的中繼資料 (Metadata)。

(繼承來源 BitmapSource)
Palette

取得點陣圖的色板 (如果有指定的話)。

(繼承來源 BitmapSource)
PixelHeight

取得點陣圖的高度 (以像素為單位)。

(繼承來源 BitmapSource)
PixelWidth

取得點陣圖的寬度 (以像素為單位)。

(繼承來源 BitmapSource)
Source

取得或設定值,這個值會識別已轉換的來源點陣圖。

SourceColorContext

取得或設定值,這個值會識別來源點陣圖的色彩設定檔。

Width

取得點陣圖的寬度,以與裝置無關的單位 (每單位 1/96 英吋) 。

(繼承來源 BitmapSource)

方法

ApplyAnimationClock(DependencyProperty, AnimationClock)

AnimationClock 套用至指定的 DependencyProperty。 如果屬性已有動畫效果,即使用 SnapshotAndReplace 遞移式行為。

(繼承來源 Animatable)
ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)

AnimationClock 套用至指定的 DependencyProperty。 如果已建立屬性的動畫,則會使用指定的 HandoffBehavior

(繼承來源 Animatable)
BeginAnimation(DependencyProperty, AnimationTimeline)

將動畫套用至指定的 DependencyProperty。 呈現下一個畫面格後,就會啟動動畫。 如果指定的屬性已有動畫效果,即使用 SnapshotAndReplace 遞移式行為。

(繼承來源 Animatable)
BeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)

將動畫套用至指定的 DependencyProperty。 呈現下一個畫面格後,就會啟動動畫。 如果已建立指定之屬性的動畫,則會使用指定的 HandoffBehavior

(繼承來源 Animatable)
BeginInit()

表示 ColorConvertedBitmap 初始化開始。

CheckAccess()

判斷呼叫的執行是否可以存取這個 DispatcherObject

(繼承來源 DispatcherObject)
CheckIfSiteOfOrigin()

檢查點陣圖來源內容是否來自已知的來源網站。 這個方法可用來確定像素複製作業是安全的。

(繼承來源 BitmapSource)
ClearValue(DependencyProperty)

清除屬性的區域數值。 要清除的屬性是由 DependencyProperty 識別項所指定。

(繼承來源 DependencyObject)
ClearValue(DependencyPropertyKey)

清除唯讀屬性的區域數值。 要清除的屬性是由 DependencyPropertyKey 所指定。

(繼承來源 DependencyObject)
Clone()

建立這個 ColorConvertedBitmap的可修改複製品,製作這個物件值的深層複本。 當複製相依性屬性時,這個方法會複製資源參考和資料繫結 (但可能無法再解析),但不會複製動畫或它們目前的值。

CloneCore(Freezable)

使這個執行個體成為指定之 BitmapSource 的深層複本。 當複製相依性屬性時,這個方法會複製資源參考和資料繫結 (但可能無法再解析),但不會複製動畫或它們目前的值。

(繼承來源 BitmapSource)
CloneCurrentValue()

建立這個 ColorConvertedBitmap 物件的可修改複製品,製作這個物件目前值的深層複本。 不會複製資源參考、資料繫結和動畫,但是會複製其目前值。

CloneCurrentValueCore(Freezable)

使用目前的屬性值,讓這個執行個體成為指定的 BitmapSource 之可修改深層複本。 不會複製資源參考、資料繫結和動畫,但是會複製其目前值。

(繼承來源 BitmapSource)
CoerceValue(DependencyProperty)

強制轉型所指定相依性屬性的值。 完成方式是叫用存在於呼叫 DependencyObject 之相依性屬性的屬性中繼資料中所指定的任何 CoerceValueCallback 函式。

(繼承來源 DependencyObject)
CopyPixels(Array, Int32, Int32)

將點陣圖像素資料複製到具有所指定步距 的像素陣列 (從指定的位移 (Offset) 開始)。

(繼承來源 BitmapSource)
CopyPixels(Int32Rect, Array, Int32, Int32)

將指定之矩形內的點陣圖像素資料,複製到具有所指定步距的像素陣列 (從指定的位移開始)。

(繼承來源 BitmapSource)
CopyPixels(Int32Rect, IntPtr, Int32, Int32)

複製指定矩形內的點陣圖像素資料。

(繼承來源 BitmapSource)
CreateInstance()

初始化 Freezable 類別的新執行個體。

(繼承來源 Freezable)
CreateInstanceCore()

在衍生類別中實作時,建立 Freezable 衍生類別的新執行個體。

(繼承來源 Freezable)
EndInit()

表示 ColorConvertedBitmap 初始化結束。

Equals(Object)

判斷提供的 DependencyObject 和目前的 DependencyObject 是否相等。

(繼承來源 DependencyObject)
Freeze()

將目前的物件設為不可修改,並將其 IsFrozen 屬性設定為 true

(繼承來源 Freezable)
FreezeCore(Boolean)

BitmapSource 的執行個體或衍生類別製作為不變的。

(繼承來源 BitmapSource)
GetAnimationBaseValue(DependencyProperty)

傳回指定之 DependencyProperty 的非動畫實值。

(繼承來源 Animatable)
GetAsFrozen()

使用基底 (非動畫) 屬性值,建立 Freezable 的凍結複本。 因為複本已凍結,所以會以傳址方式複製任何凍結子物件。

(繼承來源 Freezable)
GetAsFrozenCore(Freezable)

使這個執行個體成為指定之 BitmapSource 物件的複製。

(繼承來源 BitmapSource)
GetCurrentValueAsFrozen()

使用目前屬性值,建立 Freezable 的凍結複本。 因為複本已凍結,所以會以傳址方式複製任何凍結子物件。

(繼承來源 Freezable)
GetCurrentValueAsFrozenCore(Freezable)

使這個執行個體成為所指定 BitmapSource 的凍結複製品。 不會複製資源參考、資料繫結和動畫,但是會複製其目前值。

(繼承來源 BitmapSource)
GetHashCode()

取得這個 DependencyObject 的雜湊碼。

(繼承來源 DependencyObject)
GetLocalValueEnumerator()

建立特定的列舉值,以判斷哪些相依性屬性在此 DependencyObject 上具有本機設定的值。

(繼承來源 DependencyObject)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetValue(DependencyProperty)

傳回 DependencyObject 的這個執行個體上之相依性屬性的目前有效值。

(繼承來源 DependencyObject)
InvalidateProperty(DependencyProperty)

重新評估指定相依性屬性的有效值。

(繼承來源 DependencyObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnChanged()

目前的 Freezable 物件遭到修改時進行呼叫。

(繼承來源 Freezable)
OnFreezablePropertyChanged(DependencyObject, DependencyObject)

確定已為剛剛設定的 DependencyObjectType 資料成員,建立適當的內容指標。

(繼承來源 Freezable)
OnFreezablePropertyChanged(DependencyObject, DependencyObject, DependencyProperty)

此成員支援Windows Presentation Foundation (WPF) 基礎結構,而且不適合直接從程式碼使用。

(繼承來源 Freezable)
OnPropertyChanged(DependencyPropertyChangedEventArgs)

覆寫 OnPropertyChanged(DependencyPropertyChangedEventArgs)DependencyObject 實作也可以叫用任何 Changed 處理常式,以回應類型 Freezable 的變更相依性屬性。

(繼承來源 Freezable)
ReadLocalValue(DependencyProperty)

傳回相依性屬性的區域值 (如果存在)。

(繼承來源 DependencyObject)
ReadPreamble()

確定 Freezable 是從有效的執行緒進行存取。 如果 API 會讀取非相依性屬性的資料成員,則 Freezable 的繼承者必須在該 API 的開頭呼叫這個方法。

(繼承來源 Freezable)
SetCurrentValue(DependencyProperty, Object)

設定相依性屬性的值,而不需要變更其值來源。

(繼承來源 DependencyObject)
SetValue(DependencyProperty, Object)

設定相依性屬性的區域值 (由相依性屬性的識別碼所指定)。

(繼承來源 DependencyObject)
SetValue(DependencyPropertyKey, Object)

設定唯讀相依性屬性的區域數值 (由相依性屬性的 DependencyPropertyKey 識別項所指定)。

(繼承來源 DependencyObject)
ShouldSerializeProperty(DependencyProperty)

傳回值,這個值表示序列化程序是否應該序列化所提供相依性屬性的值。

(繼承來源 DependencyObject)
ToString()

根據目前的文化特性,建立這個物件的字串表示。

(繼承來源 ImageSource)
ToString(IFormatProvider)

根據傳入的 IFormatProvider,建立這個物件的字串表示。 如果提供者為 null,則會使用 CurrentCulture

(繼承來源 ImageSource)
VerifyAccess()

請強制執行可以存取這個 DispatcherObject 的呼叫執行緒。

(繼承來源 DispatcherObject)
WritePostscript()

引發 FreezableChanged 事件,並叫用其 OnChanged() 方法。 在任何 API 修改未以相依性屬性儲存的類別成員之後,衍生自 Freezable 的類別應該在 API 的結尾呼叫這個方法。

(繼承來源 Freezable)
WritePreamble()

確認 Freezable 未凍結,而且是從有效的執行緒內容進行存取。 在任何 API 將資料寫入至非相依性屬性的資料成員之前,Freezable 繼承者應該在 API 的開頭呼叫這個方法。

(繼承來源 Freezable)

事件

Changed

發生於 Freezable 或所含的物件遭到修改時。

(繼承來源 Freezable)
DecodeFailed

當影像因影像標頭損毀而無法載入時發生。

(繼承來源 BitmapSource)
DownloadCompleted

點陣圖內容下載完成時發生。

(繼承來源 BitmapSource)
DownloadFailed

無法下載點陣圖內容時發生。

(繼承來源 BitmapSource)
DownloadProgress

點陣圖內容的下載進度變更時發生。

(繼承來源 BitmapSource)

明確介面實作

IFormattable.ToString(String, IFormatProvider)

使用指定的格式,格式化目前執行個體的值。

(繼承來源 ImageSource)

適用於

另請參閱