找传奇、传世资源到传世资源站!

c# 视频动态绘制 例子源码下载

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

c# 视频动态绘制 例子源码下载 C#语言基础-第1张using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Ink;using System.Windows.Input;using System.Windows.Input.StylusPlugIns;using System.Windows.Media;using System.Windows.Media.Imaging;namespace A._1{ public class InkVideo : DynamicRenderer { public InkVideoStroke InkStroke { private set; get; } private Point prevPoint; private MediaPlayer media=new MediaPlayer(); public void CreateNewStroke(InkCanvasStrokeCollectedEventArgs e) { InkStroke = new InkVideoStroke(this, e.Stroke.StylusPoints); } protected override void OnStylusDown(RawStylusInput rawStylusInput) { prevPoint = (Point)rawStylusInput.GetStylusPoints().First(); base.OnStylusDown(rawStylusInput); } protected override void OnStylusMove(RawStylusInput rawStylusInput) { StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints(); this.Reset(Stylus.CurrentStylusDevice, stylusPoints); base.OnStylusMove(rawStylusInput); } public Point Draw(Point first,MediaPlayer mp, DrawingContext dc, StylusPointCollection points) { // MainWindow main = new MainWindow(); // videoName=this.Name; // if (videoName != null) //{ mp.Open(new Uri(MainWindow.videoName, UriKind.Relative)); //} Point pt = (Point)points.Last(); Vector v = Point.Subtract(pt, first); if (v.Length > 4) { Rect rect = new Rect(first, v); mp.Play(); dc.DrawVideo(mp, rect); } return first; } protected override void OnDraw(DrawingContext drawingContext, StylusPointCollection stylusPoints, Geometry geometry, Brush fillBrush) { prevPoint = Draw(prevPoint,media,drawingContext, stylusPoints); //base.OnDraw(drawingContext, stylusPoints, geometry, fillBrush); } } public class InkVideoStroke : Stroke { MediaPlayer mp ; InkVideo ink; public InkVideoStroke(InkVideo ink, StylusPointCollection stylusPoints) : base(stylusPoints) { this.ink = ink; mp = new MediaPlayer(); this.DrawingAttributes.Color = Colors.Transparent; } protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { base.DrawCore(drawingContext, drawingAttributes); Point pt = (Point)StylusPoints.First(); ink.Draw(pt, mp,drawingContext, StylusPoints); } } }

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复