BitmapDecoder.CreateInPlaceBitmapMetadataWriter 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建 InPlaceBitmapMetadataWriter 的一个实例,它可以用于更新位图的元数据。
public:
virtual System::Windows::Media::Imaging::InPlaceBitmapMetadataWriter ^ CreateInPlaceBitmapMetadataWriter();
public virtual System.Windows.Media.Imaging.InPlaceBitmapMetadataWriter CreateInPlaceBitmapMetadataWriter ();
abstract member CreateInPlaceBitmapMetadataWriter : unit -> System.Windows.Media.Imaging.InPlaceBitmapMetadataWriter
override this.CreateInPlaceBitmapMetadataWriter : unit -> System.Windows.Media.Imaging.InPlaceBitmapMetadataWriter
Public Overridable Function CreateInPlaceBitmapMetadataWriter () As InPlaceBitmapMetadataWriter
返回
InPlaceBitmapMetadataWriter 的一个实例。
例外
此源自文件的图像流是只读的。
此解码器不是内置的解码器。
示例
下面的代码示例演示如何创建 以 InPlaceBitmapMetadataWriter 更新与位图图像关联的元数据。
Stream^ pngStream = gcnew FileStream("smiley.png", FileMode::Open, FileAccess::ReadWrite, FileShare::ReadWrite);
PngBitmapDecoder^ pngDecoder = gcnew PngBitmapDecoder(pngStream, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
BitmapFrame^ pngFrame = pngDecoder->Frames[0];
InPlaceBitmapMetadataWriter^ pngInplace = pngFrame->CreateInPlaceBitmapMetadataWriter();
if (pngInplace->TrySave() == true)
{
pngInplace->SetQuery("/Text/Description", "Have a nice day.");
}
pngStream->Close();
Stream pngStream = new System.IO.FileStream("smiley.png", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
PngBitmapDecoder pngDecoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapFrame pngFrame = pngDecoder.Frames[0];
InPlaceBitmapMetadataWriter pngInplace = pngFrame.CreateInPlaceBitmapMetadataWriter();
if (pngInplace.TrySave() == true)
{ pngInplace.SetQuery("/Text/Description", "Have a nice day."); }
pngStream.Close();
Dim pngStream As New System.IO.FileStream("smiley.png", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
Dim pngDecoder As New PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default)
Dim pngFrame As BitmapFrame = pngDecoder.Frames(0)
Dim pngInplace As InPlaceBitmapMetadataWriter = pngFrame.CreateInPlaceBitmapMetadataWriter()
If pngInplace.TrySave() = True Then
pngInplace.SetQuery("/Text/Description", "Have a nice day.")
End If
pngStream.Close()