我使用它从uri加载图像,然后用.xaml页面中定义的动画(Storyboard)显示它:
var coverBitmap = new BitmapImage(urlToNewCover)
{
CreateOptions = BitmapCreateOptions.None
};
coverBitmap.ImageOpened += async (s, args) => SetLookFromLoadedBitmap(coverBitmap, track);
private void SetLookFromLoadedBitmap(BitmapImage coverBitmap, AudioTrack track)
{
SetCoverAndBackground(coverBitmap);
SetLabelsByTrack(track);
CoverImageSlideIn.Begin();
}
private void SetCoverAndBackground(BitmapImage bm)
{
ImgAlbumCover.Source = bm;
ImgAlbumCoverCD.Visibility = Visibility.Collapsed;
ChangeImageForBackground(bm);
}
private void ChangeImageForBackground(object s)
{
var wb = ImageHelpers.BlurBitmap((BitmapImage)s);
var brush = new ImageBrush { ImageSource = wb };
LayoutRoot.Background = brush;
}
它正常工作,没关系。但是,当我使用隔离存储中的图像尝试它时,动画不会启动。图像刚刚显示。
var coverBitmap = new BitmapImage();
using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isf.FileExists(track.AlbumArt.OriginalString))
{
using (var sourceFile = isf.OpenFile(track.AlbumArt.OriginalString, FileMode.Open, FileAccess.Read))
{
coverBitmap.SetSource(sourceFile);
}
}
}
SetLookFromLoadedBitmap(coverBitmap, track);
怎么了?我该如何解决?感谢
答案 0 :(得分:0)
我的回答,嗯:)
string localFolderPath = ApplicationData.Current.LocalFolder.Path; Path.Combine( localFolderPath, track.AlbumArt.OriginalString );