如何使用存储在独立存储图像的分镜动画? [英] How to use images stored in isolated storage for a storyboard animation?
问题描述
我似乎无法得到我已存储在独立存储出现在我的故事板的图片,我可以输出图像到屏幕上,而我拍照与摄像头,但后来当我使用相同的文件名值=的String.Format(MYIMAGE {0:D2} .JPG,我)
因为我在那里它们存放它似乎不工作,我应该再次打开隔离存储在故事板。我现在用的是蜡烛动画教程 rel=\"nofollow\">但这些图像是静态保存在文件夹中。谁能帮助我将不胜感激大大的感谢。
修改
我可以从独立存储打开一个图像,但它是最后一个出现的形象,我不知道如果它正在运行的动画,因为它只有一个形象,任何人都可以帮忙吗?的代码是在第二个职位低于的
私人无效PlayButton_Click(对象发件人,RoutedEventArgs E)
{
AnimationPanel.Visibility = Visibility.Visible;
=分镜故事板新
{
的repeatBehavior = RepeatBehavior.Forever
};
变种动画=新ObjectAnimationUsingKeyFrames();
Storyboard.SetTarget(动画,CandleImage);
Storyboard.SetTargetProperty(动画,新的PropertyPath(源));
storyboard.Children.Add(动画);
的for(int i = 0; I< = savedCounter;我++)
{
无功的关键帧=新DiscreteObjectKeyFrame
{
KeyTime = KeyTime。 FromTimeSpan(TimeSpan.FromMilliseconds(50 * I)),
值=的String.Format(MYIMAGE {0:D2} .JPG,我)//从孤立的存储
图像};
animation.KeyFrames.Add(关键帧);
}
Resources.Add(CandleStoryboard,故事情节);
storyboard.Begin();
}
}
修改
我可以打开独立存储一幅图像,但它是出现,我不知道如果它正在运行的动画,因为它只有一个形象,谁能帮助最后的图像?谢谢
下面是我使用
代码
为(INT I = 0; I< savedCounter;我++)
{
试
{
image.SetSource(isStore.OpenFile(MYIMAGE+ I +JPG。 FileMode.Open));从孤立的存储
}
赶上(例外)
{
// //图像扔;
}
无功的关键帧=新DiscreteObjectKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(50 * I)) ,
值=图像
};
animation.KeyFrames.Add(关键帧);
}
Resources.Add(CandleStoryboard,故事情节);
storyboard.Begin();
}
,否则
{
storyboard.Stop();
}
}
在我的编辑以上我不得不搬到一个BitmapImage的循环中,因为每次都需要一个新的实例,了一段时间发现,但现在的工作。
I can't seem to get the images I have stored in isolated storage to appear in my story board, I can output the images onto the screen while I take a picture with the camera but then when I use the same filename Value = String.Format("MyImage{0:D2}.jpg", i)
as where I stored them it doesn't seem to work should I be opening isolated storage again in the storyboard. I am using the candle animation tutorial here but these images are in a folder saved statically. can anyone help I would appreciate it greatly thanks.
EDIT I can open one Image from isolated storage but it is the last image that appears, I dont even know if it is running the animation as it's only one image, Can anyone help? code is in second post below
private void PlayButton_Click(object sender, RoutedEventArgs e)
{
AnimationPanel.Visibility = Visibility.Visible;
storyboard = new Storyboard
{
RepeatBehavior = RepeatBehavior.Forever
};
var animation = new ObjectAnimationUsingKeyFrames();
Storyboard.SetTarget(animation, CandleImage);
Storyboard.SetTargetProperty(animation, new PropertyPath("Source"));
storyboard.Children.Add(animation);
for (int i = 0; i <= savedCounter; i++)
{
var keyframe = new DiscreteObjectKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(50 * i)),
Value = String.Format("MyImage{0:D2}.jpg", i)//images from isolated storage
};
animation.KeyFrames.Add(keyframe);
}
Resources.Add("CandleStoryboard", storyboard);
storyboard.Begin();
}
}
EDIT I can open one Image from isolated storage but it is the last image that appears, I dont even know if it is running the animation as it's only one image, Can anyone help? Thanks
here is the code I am using
for (int i = 0; i < savedCounter; i++)
{
try
{
image.SetSource(isStore.OpenFile("MyImage"+i+".jpg", FileMode.Open));//images from isolated storage
}
catch (Exception)
{
//throw;
}
var keyframe = new DiscreteObjectKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(50 * i)),
Value = image
};
animation.KeyFrames.Add(keyframe);
}
Resources.Add("CandleStoryboard", storyboard);
storyboard.Begin();
}
else
{
storyboard.Stop();
}
}
In my edit above I had to move a BitmapImage inside the loop as it needs a new instance each time, took awhile to find but as is working now.
这篇关于如何使用存储在独立存储图像的分镜动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!