BitmapMetadata.GetQuery(String) Methode

Definition

Bietet Zugriff auf einen Metadatenabfrageleser, der Metadaten aus einer Bitmapbilddatei extrahieren kann.

public:
 System::Object ^ GetQuery(System::String ^ query);
[System.Security.SecurityCritical]
public object GetQuery(string query);
public object GetQuery(string query);
[<System.Security.SecurityCritical>]
member this.GetQuery : string -> obj
member this.GetQuery : string -> obj
Public Function GetQuery (query As String) As Object

Parameter

query
String

Gibt die Zeichenfolge an, die im aktuellen BitmapMetadata Objekt abgefragt wird.

Gibt zurück

Die Metadaten am angegebenen Abfragespeicherort.

Attribute

Ausnahmen

query ist null.

Beispiele

Im folgenden Codebeispiel wird die Verwendung der SetQuery Methode zum Schreiben von Metadaten in eine PNG-Datei (Portable Network Graphics) veranschaulicht.

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())
{
   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())
{ 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 die GetQuery Methode zum Lesen dieser Daten und zum Ausgeben als Textzeichenfolge verwendet.


// 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, aber nicht für die Anzeige des Bilds erforderlich sind. Jedes unterstützte Bitmapbildformat behandelt Metadaten unterschiedlich, aber die Möglichkeit zum Lesen und Schreiben von Metadaten ist identisch.

Windows Presentation Foundation (WPF) unterstützt die folgenden Bildmetadatenschemas: Exchangeable Image File (Exif), tEXt (PNG Textual Data), Image File Directory (IFD), International Press Telecommunications Council (IPTC) und Extensible Metadata Platform (XMP).

Gilt für:

Weitere Informationen