Cas*_*ius 5 xmp win-universal-app
使用WIC,我可以编写有关标记人员的 xmp信息: 人员标记概述
现在我试图在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);
}
}
Run Code Online (Sandbox Code Playgroud)
有没有人有想法或建议?
谢谢
小智 3
这对我有用:
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));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
226 次 |
| 最近记录: |