问题描述
我正在寻找一个很好的解决方案,以便从编程环境中的图像创建幻灯片视频(因此,除非它是命令行或与.NET C#集成,否则我不能使用该组件)...到目前为止我还没有找到低于400美元的组件来完成Ken Burns(平移和缩放效果),整合音乐并产生视频文件的功能.
所以!我发现除了平移和缩放效果之外,还有很多组件可以完成所有工作,我希望有人可以推荐一个更好的组件,或者为我提供线索或链接,或者链接到适当的文章,以充分解释我可以编写一些代码的效果进行图像处理(使我的起始jpg和其他jpg字符串具有相同的效果)
I''m looking for a good solution to create slideshow videos from images from within a programming environment (so I can''t use a component unless it is command line or integrates with .NET C#)... So far I have not found any components less than $400 that will do Ken Burns (Pan and Zoom effects), integrate music, and produce a video file.
So! I''ve found many components that do everything except the pan and zooming effect, and I am hoping someone could either recommend a better component OR give me a clue or link to a proper article explaining enough about the effect that I could write some code to do image manipulation (take my starting jpg and string additional jpgs to the same effect)
推荐答案
<Window x:Class="MoveAndZoom.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="500" Width="500">
<Canvas Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" x:Name="ImageHolder" >
<Image Canvas.Left="0" MouseWheel="Img_MouseWheel" MouseMove="Img_MouseMove"
MouseDown="Img_MouseDown" MouseUp="Img_MouseUp" Panel.ZIndex="0"
Cursor="Hand" Canvas.Top="0" Height="150" Width="150" Source="sketch.jpg"
x:Name="Img">
</Image>
</Canvas>
</Window>
和后面的代码是
and the Code Behind are
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MoveAndZoom
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
Point p;
public Window1()
{
InitializeComponent();
}
private void Img_MouseWheel(object sender, MouseWheelEventArgs e)
{
Img.Height += e.Delta;
Img.Width += e.Delta;
}
private void Img_MouseMove(object sender, MouseEventArgs e)
{
Point x = e.GetPosition(ImageHolder);
if (e.LeftButton == MouseButtonState.Pressed)
{
Canvas.SetLeft(Img, Canvas.GetLeft(Img) + (x.X - p.X));
Canvas.SetTop(Img, Canvas.GetTop(Img) + (x.Y - p.Y));
}
p = x;
}
private void Img_MouseDown(object sender, MouseButtonEventArgs e)
{
Img.CaptureMouse();
p = e.GetPosition(ImageHolder);
}
private void Img_MouseUp(object sender, MouseButtonEventArgs e)
{
Img.ReleaseMouseCapture();
}
}
}
您也可以对视频使用相同的代码
U can use the Same codes for Videos too
这篇关于尝试找到有关幻灯片放映和效果的指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!