Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
InPlaceBitmapMetadataWriter Class

Enables in-place updates to existing blocks of BitmapMetadata.

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic (Declaration)
Public NotInheritable Class InPlaceBitmapMetadataWriter _
    Inherits BitmapMetadata
Visual Basic (Usage)
Dim instance As InPlaceBitmapMetadataWriter
C#
public sealed class InPlaceBitmapMetadataWriter : BitmapMetadata
Visual C++
public ref class InPlaceBitmapMetadataWriter sealed : public BitmapMetadata
JScript
public final class InPlaceBitmapMetadataWriter extends BitmapMetadata
XAML
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.

Visual Basic
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()
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() == true)
{ pngInplace.SetQuery("/Text/Description", "Have a nice day."); }
pngStream.Close();
Visual C++
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();
System..::.Object
  System.Windows.Threading..::.DispatcherObject
    System.Windows..::.DependencyObject
      System.Windows..::.Freezable
        System.Windows.Media..::.ImageMetadata
          System.Windows.Media.Imaging..::.BitmapMetadata
            System.Windows.Media.Imaging..::.InPlaceBitmapMetadataWriter
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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker