BitmapImage 類別

定義

使用 Extensible Application Markup Language (XAML),提供針對載入影像最佳化的特殊化 BitmapSource

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

範例

下列程式碼範例示範如何在 BitmapImage 可延伸的應用程式標記語言中使用 (XAML) 和程式碼。

<!-- Property Tag XAML Syntax -->
<Image Width="200"  Margin="5" Grid.Column="1" Grid.Row="1" >
   <Image.Source>
      <BitmapImage UriSource="sampleImages/bananas.jpg" />
   </Image.Source>
</Image>
<!-- Property Tag XAML Syntax -->
<Image Width="200"  Margin="5" Grid.Column="1" Grid.Row="1" >
   <Image.Source>
      <BitmapImage UriSource="sampleImages/bananas.jpg" />
   </Image.Source>
</Image>
// Create the image element.
Image simpleImage = new Image();    
simpleImage.Width = 200;
simpleImage.Margin = new Thickness(5);

// Create source.
BitmapImage bi = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block.
bi.BeginInit();
bi.UriSource = new Uri(@"/sampleImages/cherries_larger.jpg",UriKind.RelativeOrAbsolute);
bi.EndInit();
// Set the image source.
simpleImage.Source = bi;
' Create the image element.
Dim simpleImage As New Image()
simpleImage.Width = 200
simpleImage.Margin = New Thickness(5)

' Create source.
Dim bi As New BitmapImage()
' BitmapImage.UriSource must be in a BeginInit/EndInit block.
bi.BeginInit()
bi.UriSource = New Uri("/sampleImages/cherries_larger.jpg", UriKind.RelativeOrAbsolute)
bi.EndInit()
' Set the image source.
simpleImage.Source = bi

備註

BitmapImage 主要存在以支援可延伸的應用程式標記語言 (XAML) 語法,並引進其他屬性來載入未定義的 BitmapSource 點陣圖。

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

BitmapImage 使用建 BitmapImage 構函式建立的物件會自動初始化,並忽略屬性變更。

建構函式

BitmapImage()

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

BitmapImage(Uri)

使用所提供的 BitmapImage,初始化 Uri 類別的新執行個體。

BitmapImage(Uri, RequestCachePolicy)

使用來源為 BitmapImage,而且根據提供之 Uri 快取的影像,初始化 RequestCachePolicy 類別的新執行個體。

欄位

CacheOptionProperty

識別 CacheOption 相依性屬性。

CreateOptionsProperty

識別 CreateOptions 相依性屬性。

DecodePixelHeightProperty

識別 DecodePixelHeight 相依性屬性。

DecodePixelWidthProperty

識別 DecodePixelWidth 相依性屬性。

RotationProperty

識別 Rotation 相依性屬性。

SourceRectProperty

識別 SourceRect 相依性屬性。

StreamSourceProperty

識別 StreamSource 相依性屬性。

UriCachePolicyProperty

識別 UriCachePolicy 相依性屬性。

UriSourceProperty

識別 UriSource 相依性屬性。

屬性

BaseUri

取得或設定值,這個值表示目前 Uri 內容的基底 BitmapImage

CacheOption

取得或設定要用於這個 BitmapCacheOption 執行個體的 BitmapImage

CanFreeze

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

(繼承來源 Freezable)
CreateOptions

取得或設定 BitmapCreateOptionsBitmapImage

DecodePixelHeight

取得或設定影像解碼成的高度 (以像素為單位)。

DecodePixelWidth

取得或設定影像解碼成的寬度 (以像素為單位)。

DependencyObjectType

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

(繼承來源 DependencyObject)
Dispatcher

取得與這個 Dispatcher 關聯的 DispatcherObject

(繼承來源 DispatcherObject)
DpiX

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

(繼承來源 BitmapSource)
DpiY

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

(繼承來源 BitmapSource)
Format

取得點陣圖資料的原生 PixelFormat

(繼承來源 BitmapSource)
HasAnimatedProperties

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

(繼承來源 Animatable)
Height

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

(繼承來源 BitmapSource)
IsDownloading

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

IsFrozen

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

(繼承來源 Freezable)
IsSealed

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

(繼承來源 DependencyObject)
Metadata

不支援。 BitmapImage 不支援 Metadata 屬性,並且會擲回 NotSupportedException

Palette

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

(繼承來源 BitmapSource)
PixelHeight

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

(繼承來源 BitmapSource)
PixelWidth

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

(繼承來源 BitmapSource)
Rotation

取得或設定這個 BitmapImage 會旋轉的角度。

SourceRect

取得或設定當成 BitmapImage 之來源的矩形。

StreamSource

取得或設定 BitmapImage 的資料流來源。

UriCachePolicy

取得或設定值,這個值表示來自 HTTP 來源之影像的快取原則。

UriSource

取得或設定 UriBitmapImage 來源。

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

表示 BitmapImage 初始化開始。

CheckAccess()

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

(繼承來源 DispatcherObject)
CheckIfSiteOfOrigin()

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

(繼承來源 BitmapSource)
ClearValue(DependencyProperty)

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

(繼承來源 DependencyObject)
ClearValue(DependencyPropertyKey)

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

(繼承來源 DependencyObject)
Clone()

建立這個 BitmapImage的可修改複製品,製作這個物件值的深層複本。

CloneCore(Freezable)

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

(繼承來源 BitmapSource)
CloneCurrentValue()

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

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

表示 BitmapImage 初始化結束。

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)

適用於

另請參閱