如何在 Universal Apps [UWP] 中编写 XMP "People Tagged"

How to write XMP "People Tagged" in Universal Apps [UWP]

使用 WIC,我可以编写关于被标记人员的 xmp 信息: People Tagging Overview

现在我想在 UWP 中做同样的事情,但它不起作用:

当我尝试只更改像“/xmp/Title”这样的简单标签时,它正在工作。

但是当我尝试更改 "PersonDisplayName" 或 "Rectangle" 时,它不起作用。

代码示例:

public async void SaveNewPeopleTagged(StorageFile file, string name , string rect)
    {
        try
        {
            using (IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.ReadWrite),
                                       memStream = new InMemoryRandomAccessStream())
            {
                BitmapDecoder decoder = await BitmapDecoder.CreateAsync(fileStream);

                // Set the encoder's destination to the temporary, in-memory stream.
                BitmapEncoder encoder = await BitmapEncoder.CreateForTranscodingAsync(memStream, decoder);

                var propertySet = new Windows.Graphics.Imaging.BitmapPropertySet();

                BitmapTypedValue btName = new BitmapTypedValue(name, Windows.Foundation.PropertyType.String);
                //"/xmp/<xmpstruct>MP:RegionInfo/<xmpbag>MPRI:Regions/PersonDisplayName" **is not working**
                propertySet.Add("/xmp/RegionInfo/Regions/PersonDisplayName", btName);

                BitmapTypedValue btRect = new BitmapTypedValue(rect, Windows.Foundation.PropertyType.String);
                //"/xmp/<xmpstruct>MP:RegionInfo/<xmpbag>MPRI:Regions/Rectangle" **is not working**
                propertySet.Add("/xmp/RegionInfo/Regions/Rectangle", btRect);

                await encoder.BitmapProperties.SetPropertiesAsync(propertySet);
                //**Give a exception... "Value does not fall within the expected range."**

                //If I use only : propertySet.Add("/xmp/Title", ...); it is working

                await encoder.FlushAsync();
                await memStream.FlushAsync();
                memStream.Seek(0);
                fileStream.Seek(0);
                fileStream.Size = 0;
                await RandomAccessStream.CopyAsync(memStream, fileStream);

            }
        }
        catch (Exception err)
        {
            Debug.WriteLine(err.Message);
        }
    }

有没有人有想法或建议?

谢谢

这对我有用:

int n = 0; // nth entry
propertySet.Add("/xmp/<xmpstruct>MP:RegionInfo/<xmpbag>MPRI:Regions/<xmpstruct>{ulong=" + n + "}/MPReg:Rectangle", new BitmapTypedValue(rect, PropertyType.String));
propertySet.Add("/xmp/<xmpstruct>MP:RegionInfo/<xmpbag>MPRI:Regions/<xmpstruct>{ulong=" + n + "}/MPReg:PersonDisplayName", new BitmapTypedValue(name, PropertyType.String));