我希望能够拍摄现有照片并将其设置为专辑插图。
我可以GetThumbnailAsync
用来给我一个缩略图并GetOutputStream
获取缩略图输出流。不幸的是,它不可写。
如何在 Win8 C# 应用程序中的项目上设置专辑插图(或任何缩略图)?
当前(非工作)代码。当 outStream 被拒绝访问错误刷新时,它会死掉
FileOpenPicker fileopenpicker = new FileOpenPicker();
fileopenpicker.FileTypeFilter.Add(".jpg");
fileopenpicker.FileTypeFilter.Add(".png");
fileopenpicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;// | PickerLocationId.DocumentsLibrary | PickerLocationId.PicturesLibrary | PickerLocationId.MusicLibrary;
var singlefileoperation = await fileopenpicker.PickSingleFileAsync();
var read = await singlefileoperation.OpenAsync(FileAccessMode.Read);
StorageFile replay = currentlyPlaying;
TimeSpan pos = ME.Position;
ME.Stop();
//curren
StorageItemThumbnail storageItemThumbnail = await currentlyPlaying.GetThumbnailAsync(ThumbnailMode.SingleItem);
IOutputStream inputStreamAt = storageItemThumbnail.GetOutputStreamAt(0);
Stream outStream = inputStreamAt.AsStreamForWrite();
var inStreamAt = read.GetInputStreamAt(0);
var inStream = inStreamAt.AsStreamForRead();
await inStream.CopyToAsync(outStream);
await outStream.FlushAsync();
outStream.Dispose();
inStream.Dispose();
inStreamAt.Dispose();