BitmapFrame.CreateInPlaceBitmapMetadataWriter Method

Definition

When overridden in a derived class, creates an instance of InPlaceBitmapMetadataWriter, which can be used to associate metadata with a BitmapFrame.

public abstract System.Windows.Media.Imaging.InPlaceBitmapMetadataWriter CreateInPlaceBitmapMetadataWriter();

Returns

An InPlaceBitmapMetadataWriter.

Examples

The following code example demonstrates how to use the BitmapFrame object to open a Portable Network Graphics (PNG) graphic and write metadata by using the CreateInPlaceBitmapMetadataWriter method.

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())
{ pngInplace.SetQuery("/Text/Description", "Have a nice day."); }
pngStream.Close();

Remarks

Metadata can only be added or edited using the CreateInPlaceBitmapMetadataWriter if the image file contains enough room for the new metadata; otherwise, metadata can be added using the Metadata property.

Applies to

Prodotto Versioni
.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, 10

See also