Bitmap​Properties​View Bitmap​Properties​View Bitmap​Properties​View Class

Definition

Provides read access to image properties and metadata. A particular instance of BitmapPropertiesView may represent the entire contents of the frame metadata, or any nested metadata block within the frame.

public sealed class BitmapPropertiesView : IBitmapPropertiesViewpublic sealed class BitmapPropertiesView : IBitmapPropertiesViewPublic NotInheritable Class BitmapPropertiesView Implements IBitmapPropertiesView
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Methods

GetPropertiesAsync(IIterable<String>) GetPropertiesAsync(IIterable<String>) GetPropertiesAsync(IIterable<String>)

Asynchronously retrieves one or more bitmap properties.

public IAsyncOperation<BitmapPropertySet> GetPropertiesAsync(IIterable<String> propertiesToRetrieve)public IAsyncOperation<BitmapPropertySet> GetPropertiesAsync(IIterable<String> propertiesToRetrieve)Public Function GetPropertiesAsync(propertiesToRetrieve As IIterable<String>) As IAsyncOperation( Of BitmapPropertySet )
Parameters
propertiesToRetrieve

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.

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.