BitmapMetadata.SetQuery(String, Object) BitmapMetadata.SetQuery(String, Object) BitmapMetadata.SetQuery(String, Object) BitmapMetadata.SetQuery(String, Object) Method

Definition

Bietet Zugriff auf einen Metadatenabfrage-Writer, der Metadaten in eine Bitmap-Bilddatei schreiben kann.Provides access to a metadata query writer that can write metadata to a bitmap image file.

public:
 void SetQuery(System::String ^ query, System::Object ^ value);
[System.Security.SecurityCritical]
public void SetQuery (string query, object value);
member this.SetQuery : string * obj -> unit
Public Sub SetQuery (query As String, value As Object)

Parameter

query
String String String String

Gibt den Speicherort der zu schreibenden Metadaten an.Identifies the location of the metadata to be written.

value
Object Object Object Object

Der Wert der zu schreibenden Metadaten.The value of the metadata to be written.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie die SetQuery -Methode verwendet wird, um Portable Network Graphics (PNG)Portable Network Graphics (PNG) Metadaten in eine Datei zu schreiben.The following code example demonstrates how to use the SetQuery method to write metadata to a Portable Network Graphics (PNG)Portable Network Graphics (PNG) file.

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

Nachdem die Metadaten geschrieben wurden, wird GetQuery die-Methode verwendet, um diese Daten zu lesen und als Text Zeichenfolge auszugeben.After the metadata is written, the GetQuery method is used to read that data and emit it as a text string.


// Add the metadata of the bitmap image to the text block.
TextBlock^ myTextBlock = gcnew TextBlock();
myTextBlock->Text = "The Description metadata of this image is: " + pngInplace->GetQuery("/Text/Description")->ToString();

// Add the metadata of the bitmap image to the text block.
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "The Description metadata of this image is: " + pngInplace.GetQuery("/Text/Description").ToString();
' Add the metadata of the bitmap image to the text block.
Dim myTextBlock As New TextBlock()
myTextBlock.Text = "The Description metadata of this image is: " + pngInplace.GetQuery("/Text/Description").ToString()

Hinweise

Metadaten, die einem Bild zugeordnet sind, sind Daten, die das Bild beschreiben, jedoch nicht für die Anzeige des Bilds erforderlich sind.Metadata that is associated with an image is data that describes the image but that is not necessary for display of the image. Jedes unterstützte Bitmap-Bildformat verarbeitet Metadaten anders, aber die Funktion zum Lesen und Schreiben von Metadaten ist identisch.Each supported bitmap image format handles metadata differently, but the facility for reading and writing metadata is the same.

Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)unterstützt die folgenden Exchangeable Image File (Exif)Exchangeable image file (Exif)bildmetadatenschemas:, Text (PNGPNG Textdaten Bilddateiverzeichnis (image file directory, IFD)image file directory (IFD)) International Press Telecommunications Council (IPTC)International Press Telecommunications Council (IPTC),, eXtensible Metadata Platform (XMP)Extensible Metadata Platform (XMP)und.supports the following image metadata schemas: Exchangeable Image File (Exif)Exchangeable image file (Exif), tEXt (PNGPNG Textual Data), Bilddateiverzeichnis (image file directory, IFD)image file directory (IFD), International Press Telecommunications Council (IPTC)International Press Telecommunications Council (IPTC), and eXtensible Metadata Platform (XMP)Extensible Metadata Platform (XMP).

Gilt für:

Siehe auch