BitmapDecoder.CreateInPlaceBitmapMetadataWriter Method

Definition

Creates an instance of InPlaceBitmapMetadataWriter, which can be used to update the metadata of a bitmap.

C#
public virtual System.Windows.Media.Imaging.InPlaceBitmapMetadataWriter CreateInPlaceBitmapMetadataWriter();

Returns

An instance of InPlaceBitmapMetadataWriter.

Exceptions

The file original image stream is read only.

The decoder is not a built in decoder.

Examples

The following code example demonstrates how to create an InPlaceBitmapMetadataWriter in order to update the metadata associated with a bitmap image.

C#
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();

Applies to

Product Versions
.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