共用方式為


BitmapDecoder.CreateInPlaceBitmapMetadataWriter 方法

定義

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

適用於

另請參閱