Dela via


BitmapPropertiesView.GetPropertiesAsync(IIterable<String>) Method

Definition

Asynchronously retrieves one or more bitmap properties.

public:
 virtual IAsyncOperation<BitmapPropertySet ^> ^ GetPropertiesAsync(IIterable<Platform::String ^> ^ propertiesToRetrieve) = GetPropertiesAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<BitmapPropertySet> GetPropertiesAsync(IIterable<winrt::hstring> const& propertiesToRetrieve);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<BitmapPropertySet> GetPropertiesAsync(IEnumerable<string> propertiesToRetrieve);
function getPropertiesAsync(propertiesToRetrieve)
Public Function GetPropertiesAsync (propertiesToRetrieve As IEnumerable(Of String)) As IAsyncOperation(Of BitmapPropertySet)

Parameters

propertiesToRetrieve

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

A collection of strings representing the property keys or queries that are being requested. Valid strings include Windows properties and Windows Imaging Component metadata queries.

Returns

Object that manages the asynchronous retrieval of the bitmap properties.

Implements

M:Windows.Graphics.Imaging.IBitmapPropertiesView.GetPropertiesAsync(System.Collections.Generic.IEnumerable{System.String}) M:Windows.Graphics.Imaging.IBitmapPropertiesView.GetPropertiesAsync(System.Collections.Generic.IEnumerable{Platform::String}) M:Windows.Graphics.Imaging.IBitmapPropertiesView.GetPropertiesAsync(System.Collections.Generic.IEnumerable{winrt::hstring})
Attributes

Remarks

The asynchronous operation produces a collection representing the requested image property keys and their values. The values are stored as BitmapTypedValue, which contains both the actual data as well as the PropertyType of the data.

A particular image may only contain some (or none) of the requested properties. In this case the collection will only have key-value pairs for the properties which were found in the image. You need to check for the existence of the property before you attempt to get data from it:

bitmapPropertiesView.getPropertiesAsync(["System.Title"]).done(function (retrievedProperties) {
  if (retrievedProperties.hasKey("System.Title")) {
	  	var titleProperty = retrievedProperties.lookup("System.Title");
	  	var title = titleProperty.value;
	 }
});

Querying for a metadata block

If you use the metadata query language to request a metadata block instead of a property, the returned value is a BitmapPropertiesView representing the metadata within that block. You can request any metadata contained within the block from the BitmapPropertiesView:

// this is equivalent to directly requesting "/app1/ifd/{ushort=274}" from bitmapPropertiesView
bitmapPropertiesView.getPropertiesAsync(["/app1/ifd"]).done(function (retrievedProperties) {
	  // var ifdBlock is a BitmapPropertiesView
	  var ifdBlock = retrievedProperties.lookup("/app1/ifd").value;
	  return ifdBlock.getPropertiesAsync(["/{ushort=274}");
}).then(function (retrievedProperties) {
	  var orientation = retrievedProperties.lookup("/{ushort=274}").value;
});

Enumerating through all the metadata within a frame

You can request all of the contents of a metadata block, including sub-blocks and properties, by passing in an empty (zero length) collection of strings. This produces a collection containing every sub-block and property within the BitmapPropertiesView ’s scope. In this way, you are able to iteratively retrieve all of the metadata contained within an image frame.

bitmapPropertiesView.getPropertiesAsync([]).done(function (retrievedProperties) {
	  var iterator = retrievedProps.first();
	  while (iterator.hasCurrent) {
		  // iterator.current gives a key-value pair of string, BitmapTypedValue
		  // nextMetadataBlock is a BitmapPropertiesView containing the sub-block
		  var nextMetadataBlock = iterator.current.value.value;
		  iterator.moveNext();
	}
});

If the image format does not support metadata, it will fail with HRESULT WINCODEC_ERR_UNSUPPORTEDOPERATION.

Applies to

See also