InPlaceBitmapMetadataWriter Class
Enables in-place updates to existing blocks of BitmapMetadata.
Assembly: PresentationCore (in PresentationCore.dll)
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.
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()
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Freezable
System.Windows.Media.ImageMetadata
System.Windows.Media.Imaging.BitmapMetadata
System.Windows.Media.Imaging.InPlaceBitmapMetadataWriter
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.