BitmapImage 類別
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
使用 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 構函式建立的物件會自動初始化,並忽略屬性變更。
Bitmap |
初始化 BitmapImage 類別的新執行個體。 |
Bitmap |
使用所提供的 BitmapImage,初始化 Uri 類別的新執行個體。 |
Bitmap |
使用來源為 BitmapImage,而且根據提供之 Uri 快取的影像,初始化 RequestCachePolicy 類別的新執行個體。 |
Cache |
識別 CacheOption 相依性屬性。 |
Create |
識別 CreateOptions 相依性屬性。 |
Decode |
識別 DecodePixelHeight 相依性屬性。 |
Decode |
識別 DecodePixelWidth 相依性屬性。 |
Rotation |
識別 Rotation 相依性屬性。 |
Source |
識別 SourceRect 相依性屬性。 |
Stream |
識別 StreamSource 相依性屬性。 |
Uri |
識別 UriCachePolicy 相依性屬性。 |
Uri |
識別 UriSource 相依性屬性。 |
Base |
取得或設定值,這個值表示目前 Uri 內容的基底 BitmapImage。 |
Cache |
取得或設定要用於這個 BitmapCacheOption 執行個體的 BitmapImage。 |
Can |
取得值,指出是否可以將物件設為不可修改。 (繼承來源 Freezable) |
Create |
取得或設定 BitmapCreateOptions 的 BitmapImage。 |
Decode |
取得或設定影像解碼成的高度 (以像素為單位)。 |
Decode |
取得或設定影像解碼成的寬度 (以像素為單位)。 |
Dependency |
DependencyObjectType取得包裝這個實例之 CLR 型別的 。 (繼承來源 DependencyObject) |
Dispatcher |
取得與這個 Dispatcher 關聯的 DispatcherObject。 (繼承來源 DispatcherObject) |
DpiX |
取得影像每英吋的水準點 (DPI) 。 (繼承來源 BitmapSource) |
DpiY |
取得影像的每英吋垂直點 (DPI) 。 (繼承來源 BitmapSource) |
Format |
取得點陣圖資料的原生 PixelFormat。 (繼承來源 BitmapSource) |
Has |
取得值,這個值表示是否有一個或多個 AnimationClock 物件與這個物件的任何一個相依性屬性相關聯。 (繼承來源 Animatable) |
Height |
取得裝置獨立單位 (每單位 1/96 英吋) 來源點陣圖的高度。 (繼承來源 BitmapSource) |
Is |
取得值,這個值表示 BitmapImage 目前是否正在下載內容。 |
Is |
取得值,該值表示物件目前是否可修改。 (繼承來源 Freezable) |
Is |
取得值,這個值表示此執行個體目前是否已密封 (唯讀)。 (繼承來源 DependencyObject) |
Metadata |
不支援。 BitmapImage 不支援 Metadata 屬性,並且會擲回 NotSupportedException。 |
Palette |
取得點陣圖的色板 (如果有指定的話)。 (繼承來源 BitmapSource) |
Pixel |
取得點陣圖的高度 (以像素為單位)。 (繼承來源 BitmapSource) |
Pixel |
取得點陣圖的寬度 (以像素為單位)。 (繼承來源 BitmapSource) |
Rotation |
取得或設定這個 BitmapImage 會旋轉的角度。 |
Source |
取得或設定當成 BitmapImage 之來源的矩形。 |
Stream |
取得或設定 BitmapImage 的資料流來源。 |
Uri |
取得或設定值,這個值表示來自 HTTP 來源之影像的快取原則。 |
Uri |
取得或設定 Uri 的 BitmapImage 來源。 |
Width |
以裝置獨立單位取得點陣圖的寬度, (每單位 1/96 英吋) 。 (繼承來源 BitmapSource) |
Changed |
發生於 Freezable 或所含的物件遭到修改時。 (繼承來源 Freezable) |
Decode |
當影像因影像標頭損毀而無法載入時發生。 (繼承來源 BitmapSource) |
Download |
點陣圖內容下載完成時發生。 (繼承來源 BitmapSource) |
Download |
無法下載點陣圖內容時發生。 (繼承來源 BitmapSource) |
Download |
點陣圖內容的下載進度變更時發生。 (繼承來源 BitmapSource) |
IFormattable. |
使用指定的格式,格式化目前執行個體的值。 (繼承來源 ImageSource) |
產品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |