This documentation is archived and is not being maintained.

InPlaceBitmapMetadataWriter Class

Enables in-place updates to existing blocks of BitmapMetadata.

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

public sealed class InPlaceBitmapMetadataWriter : BitmapMetadata
You cannot directly create an instance of this class in XAML.

If BitmapMetadata is not associated with a BitmapFrame that is obtained through a BitmapDecoder, the attempt to write metadata by using the in-place writer will fail. Successful write operations apply the metadata directly to the image stream by means of a decoder.

In-place metadata updates fail if an attempt is made to write metadata that a given bitmap format does not support.

To perform in-place metadata edits, the bitmap must be decoded using either the Default or OnDemand cache options. OnLoad does not guarantee access to the metadata stream needed for in-place metadata edits.

This example shows how you can modify metadata within an image without having to re-encode the image.

The following example uses an InplaceBitmapMetadataWriter to write metadata into an image. For the complete sample, see BitmapMetadata Sample.

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."); }


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0