WPF图片动画问题
现在有个功能是根据第二张图做一个动画,画成第一张图的字母。
求高人指导 WPF
[解决办法]
拿blend做关键帧动画即可
[解决办法]
如果只是用一些连续的图片实现动画效果,可以试试。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using IO = System.IO;
namespace WpfImageAnimation
{
public partial class Window1 : Window
{
readonly IEnumerable<BitmapImage> _images;
IEnumerator<BitmapImage> _imageEnum;
public Window1()
{
InitializeComponent();
this.Loaded += this.Window1_Loaded;
string exe = Assembly.GetExecutingAssembly().Location;
string exeDir = IO.Path.GetDirectoryName(exe);
string imgDir = IO.Path.Combine(exeDir, "images");
_images =
from file in IO.Directory.GetFiles(imgDir, "*.png")
orderby file
let uri = new Uri(file, UriKind.Absolute)
select new BitmapImage(uri);
}
void Window1_Loaded(object sender, RoutedEventArgs e)
{
var timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(180);
timer.Tick += this.timer_Tick;
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
if (_imageEnum == null
[解决办法]
!_imageEnum.MoveNext())
{
_imageEnum = _images.GetEnumerator();
_imageEnum.MoveNext();
}
this.image.Source = _imageEnum.Current;
}
}
}