它在Microsoft Band SDK文档中说过有关使用WriteableBitmap创建图块图标的方法,但是如何获得它以指向为图块制作的现有图像呢?
如果您的Windows Phone应用程序具有名为“ Assets / Icon1.png”的资产,则可以通过以下方式将该资产制成BandIcon:
using Microsoft.Band;
using Microsoft.Band.Tiles;
using Microsoft.Band.Tiles.Pages;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Imaging;
...
StorageFile imageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Icon1.png"));
using (IRandomAccessStream fileStream = await imageFile.OpenAsync(FileAccessMode.Read)
{
WriteableBitmap bitmap = new WriteableBitmap(1,1);
await bitmap.SetSourceAsync(fileStream);
return bitmap.ToBandIcon();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句