BitmapMetadata.GetQuery(String) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Biedt toegang tot een metagegevensquerylezer waarmee metagegevens uit een bitmapafbeeldingsbestand kunnen worden geëxtraheerd.
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
Parameters
- query
- String
Identificeert de tekenreeks die wordt opgevraagd in het huidige BitmapMetadata object.
Retouren
De metagegevens op de opgegeven querylocatie.
- Kenmerken
Uitzonderingen
query is null.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de SetQuery methode gebruikt om metagegevens te schrijven naar een PNG-bestand (Portable Network Graphics).
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()
Nadat de metagegevens zijn geschreven, wordt de GetQuery methode gebruikt om die gegevens te lezen en te verzenden als een tekenreeks.
// 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()
Opmerkingen
Metagegevens die zijn gekoppeld aan een afbeelding zijn gegevens die de afbeelding beschrijven, maar die niet nodig zijn om de afbeelding weer te geven. Elke ondersteunde bitmapafbeeldingsindeling verwerkt metagegevens anders, maar de faciliteit voor het lezen en schrijven van metagegevens is hetzelfde.
Windows Presentation Foundation (WPF) ondersteunt de volgende schema's voor afbeeldingsmetagegevens: Exchangeable image file (Exif), tEXt (PNG Textual Data), image file directory (IFD), International Press Telecommunications Council (IPTC) en Extensible Metadata Platform (XMP).