BitmapEncoder.Save(Stream) 方法

定义

将位图图像编码为指定的 Stream

public:
 virtual void Save(System::IO::Stream ^ stream);
[System.Security.SecurityCritical]
public virtual void Save (System.IO.Stream stream);
public virtual void Save (System.IO.Stream stream);
[<System.Security.SecurityCritical>]
abstract member Save : System.IO.Stream -> unit
override this.Save : System.IO.Stream -> unit
abstract member Save : System.IO.Stream -> unit
override this.Save : System.IO.Stream -> unit
Public Overridable Sub Save (stream As Stream)

参数

stream
Stream

标识此位图编码为的文件流。

属性

例外

已对位图进行编码。

Frames 计数小于或等于零。

示例

以下示例演示如何使用派生 TiffBitmapEncoder 类将位图图像保存到文件流。

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

注解

在此 API 的上下文中,“save”和“encode”是同义词。

适用于

另请参阅