BitmapFrame.Create 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
BitmapFrame基于提供的自变量创建新的参数。
重载
Create(Stream)
从给定BitmapFrame创建一个新Stream项。
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::IO::Stream ^ bitmapStream);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.IO.Stream bitmapStream);
static member Create : System.IO.Stream -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapStream As Stream) As BitmapFrame
参数
- bitmapStream
- Stream
Stream用于构造 BitmapFrame.
返回
一个来自给定BitmapFrame的 。Stream
注解
bitmapStream仅当使用缓存选项时,才能在创建帧后OnLoad关闭该帧。 默认 OnDemand 缓存选项将保留流,直到需要帧。 使用该方法 Create(Stream, BitmapCreateOptions, BitmapCacheOption) 指定创建和缓存选项。
适用于
Create(Uri)
从给定BitmapFrame创建一个新Uri项。
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(Uri ^ bitmapUri);
public static System.Windows.Media.Imaging.BitmapFrame Create(Uri bitmapUri);
static member Create : Uri -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapUri As Uri) As BitmapFrame
参数
- bitmapUri
- Uri
标识 Uri 的源的 BitmapFrame。
返回
一个来自给定BitmapFrame的 。Uri
示例
下面的代码示例演示如何从给定BitmapFrame的构造 。Uri
int width = 128;
int height = width;
int stride = width/8;
byte[] pixels = new byte[height*stride];
// Try creating a new image with a custom palette.
List<System.Windows.Media.Color> colors = new List<System.Windows.Media.Color>();
colors.Add(System.Windows.Media.Colors.Red);
colors.Add(System.Windows.Media.Colors.Blue);
colors.Add(System.Windows.Media.Colors.Green);
BitmapPalette myPalette = new BitmapPalette(colors);
// Creates a new empty image with the pre-defined palette
BitmapSource image = BitmapSource.Create(
width,
height,
96,
96,
PixelFormats.Indexed1,
myPalette,
pixels,
stride);
FileStream stream = new FileStream("empty.tif", FileMode.Create);
TiffBitmapEncoder encoder = new TiffBitmapEncoder();
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString();
encoder.Frames.Add(BitmapFrame.Create(image));
MessageBox.Show(myPalette.Colors.Count.ToString());
encoder.Save(stream);
Dim width As Integer = 128
Dim height As Integer = width
Dim stride As Integer = CType(width / 8, Integer)
Dim pixels(height * stride) As Byte
' Try creating a new image with a custom palette.
Dim colors As New List(Of System.Windows.Media.Color)()
colors.Add(System.Windows.Media.Colors.Red)
colors.Add(System.Windows.Media.Colors.Blue)
colors.Add(System.Windows.Media.Colors.Green)
Dim myPalette As New BitmapPalette(colors)
' Creates a new empty image with the pre-defined palette
Dim image As BitmapSource = System.Windows.Media.Imaging.BitmapSource.Create(width, height, 96, 96, PixelFormats.Indexed1, myPalette, pixels, stride)
Dim stream As New FileStream("empty.tif", FileMode.Create)
Dim encoder As New TiffBitmapEncoder()
Dim myTextBlock As New TextBlock()
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString()
encoder.Frames.Add(BitmapFrame.Create(image))
MessageBox.Show(myPalette.Colors.Count.ToString())
encoder.Save(stream)
适用于
Create(BitmapSource)
从给定BitmapFrame创建一个新BitmapSource项。
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::Windows::Media::Imaging::BitmapSource ^ source);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.Windows.Media.Imaging.BitmapSource source);
static member Create : System.Windows.Media.Imaging.BitmapSource -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (source As BitmapSource) As BitmapFrame
参数
- source
- BitmapSource
BitmapSource用于构造此BitmapFrame项的 。
返回
一个来自给定BitmapFrame的 。BitmapSource
适用于
Create(Uri, RequestCachePolicy)
使用指定的BitmapFrame值从给定Uri创建一个 RequestCachePolicy 。
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(Uri ^ bitmapUri, System::Net::Cache::RequestCachePolicy ^ uriCachePolicy);
public static System.Windows.Media.Imaging.BitmapFrame Create(Uri bitmapUri, System.Net.Cache.RequestCachePolicy uriCachePolicy);
static member Create : Uri * System.Net.Cache.RequestCachePolicy -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapUri As Uri, uriCachePolicy As RequestCachePolicy) As BitmapFrame
参数
- bitmapUri
- Uri
从中创建 BitmapFrame 位图的位置。
- uriCachePolicy
- RequestCachePolicy
此 BitmapFrame缓存要求。
返回
来自具有指定项BitmapFrame的给定Uri的 A RequestCachePolicy 。
注解
.NET Framework 版本 3.5 中引入了 Create(Uri, RequestCachePolicy)。 有关详细信息,请参阅 版本和依赖项。
适用于
Create(BitmapSource, BitmapSource)
BitmapFrame使用指定的缩略图从给定BitmapSource项创建新项。
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::Windows::Media::Imaging::BitmapSource ^ source, System::Windows::Media::Imaging::BitmapSource ^ thumbnail);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.Windows.Media.Imaging.BitmapSource source, System.Windows.Media.Imaging.BitmapSource thumbnail);
static member Create : System.Windows.Media.Imaging.BitmapSource * System.Windows.Media.Imaging.BitmapSource -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (source As BitmapSource, thumbnail As BitmapSource) As BitmapFrame
参数
- source
- BitmapSource
从中 BitmapFrame 构造源。
- thumbnail
- BitmapSource
生成的 BitmapFrame缩略图。
返回
具有指定缩略图的给定BitmapFrame的 ABitmapSource。
适用于
Create(Stream, BitmapCreateOptions, BitmapCacheOption)
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::IO::Stream ^ bitmapStream, System::Windows::Media::Imaging::BitmapCreateOptions createOptions, System::Windows::Media::Imaging::BitmapCacheOption cacheOption);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.IO.Stream bitmapStream, System.Windows.Media.Imaging.BitmapCreateOptions createOptions, System.Windows.Media.Imaging.BitmapCacheOption cacheOption);
static member Create : System.IO.Stream * System.Windows.Media.Imaging.BitmapCreateOptions * System.Windows.Media.Imaging.BitmapCacheOption -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapStream As Stream, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption) As BitmapFrame
参数
- bitmapStream
- Stream
从中构造此 BitmapFrame 流的流。
- createOptions
- BitmapCreateOptions
用于创建此 BitmapFrame项的选项。
- cacheOption
- BitmapCacheOption
用于创建此 BitmapFrame项的缓存选项。
返回
BitmapFrame从Stream具有指定BitmapCreateOptions和 BitmapCacheOption.
注解
OnLoad如果要在创建位图后关闭bitmapStream缓存选项,请使用缓存选项。 默认 OnDemand 缓存选项将保留对流的访问,直到需要位图并由垃圾回收器处理清理。
适用于
Create(Uri, BitmapCreateOptions, BitmapCacheOption)
从具有指定和 . 的给定BitmapFrame创建一个 Uri 。BitmapCreateOptionsBitmapCacheOption
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(Uri ^ bitmapUri, System::Windows::Media::Imaging::BitmapCreateOptions createOptions, System::Windows::Media::Imaging::BitmapCacheOption cacheOption);
public static System.Windows.Media.Imaging.BitmapFrame Create(Uri bitmapUri, System.Windows.Media.Imaging.BitmapCreateOptions createOptions, System.Windows.Media.Imaging.BitmapCacheOption cacheOption);
static member Create : Uri * System.Windows.Media.Imaging.BitmapCreateOptions * System.Windows.Media.Imaging.BitmapCacheOption -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapUri As Uri, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption) As BitmapFrame
参数
- bitmapUri
- Uri
从中创建 BitmapFrame 位图的位置。
- createOptions
- BitmapCreateOptions
用于创建此 BitmapFrame项的选项。
- cacheOption
- BitmapCacheOption
用于创建此 BitmapFrame项的缓存选项。
返回
来自具有指定BitmapFrame值和Uri的给定BitmapCreateOptions的 ABitmapCacheOption。
适用于
Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)
从具有指定BitmapFrame值UriBitmapCreateOptions和的给定BitmapCacheOption创建一个 RequestCachePolicy 。
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(Uri ^ bitmapUri, System::Windows::Media::Imaging::BitmapCreateOptions createOptions, System::Windows::Media::Imaging::BitmapCacheOption cacheOption, System::Net::Cache::RequestCachePolicy ^ uriCachePolicy);
public static System.Windows.Media.Imaging.BitmapFrame Create(Uri bitmapUri, System.Windows.Media.Imaging.BitmapCreateOptions createOptions, System.Windows.Media.Imaging.BitmapCacheOption cacheOption, System.Net.Cache.RequestCachePolicy uriCachePolicy);
static member Create : Uri * System.Windows.Media.Imaging.BitmapCreateOptions * System.Windows.Media.Imaging.BitmapCacheOption * System.Net.Cache.RequestCachePolicy -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapUri As Uri, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption, uriCachePolicy As RequestCachePolicy) As BitmapFrame
参数
- bitmapUri
- Uri
从中创建 BitmapFrame 位图的位置。
- createOptions
- BitmapCreateOptions
用于创建此 BitmapFrame项的选项。
- cacheOption
- BitmapCacheOption
用于创建此 BitmapFrame项的缓存选项。
- uriCachePolicy
- RequestCachePolicy
此 BitmapFrame缓存要求。
返回
从具有指定BitmapFrame值Uri和BitmapCreateOptions的给定BitmapCacheOption的 ARequestCachePolicy。
注解
.NET Framework 版本 3.5 中引入了 Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)。 有关详细信息,请参阅 版本和依赖项。
适用于
Create(BitmapSource, BitmapSource, BitmapMetadata, ReadOnlyCollection<ColorContext>)
使用指定的缩略图从给定BitmapFrame项创建一个新BitmapSource项,BitmapMetadata以及 ColorContext。
public:
static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::Windows::Media::Imaging::BitmapSource ^ source, System::Windows::Media::Imaging::BitmapSource ^ thumbnail, System::Windows::Media::Imaging::BitmapMetadata ^ metadata, System::Collections::ObjectModel::ReadOnlyCollection<System::Windows::Media::ColorContext ^> ^ colorContexts);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.Windows.Media.Imaging.BitmapSource source, System.Windows.Media.Imaging.BitmapSource thumbnail, System.Windows.Media.Imaging.BitmapMetadata metadata, System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Media.ColorContext> colorContexts);
static member Create : System.Windows.Media.Imaging.BitmapSource * System.Windows.Media.Imaging.BitmapSource * System.Windows.Media.Imaging.BitmapMetadata * System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Media.ColorContext> -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (source As BitmapSource, thumbnail As BitmapSource, metadata As BitmapMetadata, colorContexts As ReadOnlyCollection(Of ColorContext)) As BitmapFrame
参数
- source
- BitmapSource
BitmapSource用于构造此BitmapFrame项的 。
- thumbnail
- BitmapSource
生成的 BitmapFrame缩略图。
- metadata
- BitmapMetadata
要与此 BitmapFrame关联的元数据。
- colorContexts
- ReadOnlyCollection<ColorContext>
ColorContext与此BitmapFrame关联的对象。
返回
具有指定缩略图的给定BitmapFrame的 ABitmapSource,BitmapMetadata以及ColorContext。