在C#中绘制视频 [英] Drawing on Video within C#

查看:203
本文介绍了在C#中绘制视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用程序,允许用户应用某些工具来分析视频和图片。我需要帮助我如何在我的表单中加载到Windows媒体播放器中的视频上绘制/写入并能够保存它。它需要能够让用户在其上绘制手绘和形状。
先谢谢,

I am making an application that will allow users to apply certain tools to analyse videos & images. I need help with how i actaully draw/write on the video loaded into windows media player within my form and being able to save it on. It needs to be able to lert the user draw freehand and shapes on it. Thanks in Advance,

Chris:)

推荐答案

对于winforms中的wmp控件来说,这是一项非常重要的任务,如果不是不可能完成的话。

This is a non-trivial, if not impossible task to accomplish with the wmp control in winforms.

我不知道如何在wmp上实际绘制,但你可以在覆盖wmp的透明面板上绘制。视频正在播放时无效,但您可以在暂停时显示绘图。我使用这种技术来绘制与wmp类似的第三方视频控件。(编辑 - 这似乎不适用于wmp控件)

I don't know of any way to actually draw on the wmp but you could draw on a transparent panel overlaid over the wmp. This will not work will the video is playing but you can show the drawing while it is paused. I have used this technique to draw over a 3rd party video control that works similarly to wmp.(Edit - this does not seem to work with the wmp control)

然而,由于真正的透明面板在winforms中也相当棘手,另一种方法是从视频中抓取图像并在覆盖的图像上绘制。再次,只有当它被暂停时。

However, as real transparent panels are also rather tricky in winforms, another way would be to grab an image from the video and draw on the overlaid image. Again, only when it is paused.

这个商业控制确实能够吸引视频。它有一个事件可以触发您可以用来绘制的每个帧。然而,最大的缺点是,你不能真正做任何太花哨的事情,因为你的绘图程序需要在绘制下一帧之前完成。

This commercial control does enable drawing over the video. It has an event that fires every frame that you can use to do the drawing. The big downside, though is that you can't really do anything too fancy as your drawing routine needs to finish before the next frame is drawn.

我强烈建议你使用WPF(即使它是winforms应用程序中托管的wpf控件)来显示您的视频。在wpf中绘制视频(包括播放视频)要容易得多。

I would strongly encourage you to use WPF(even if its a wpf control hosted within a winforms app) to show your video. It is a whole lot easier to draw on video(including playing video) in wpf.

编辑

我刚测试了使用wmp绘制wmp透明面板,它不像我的第三方控件那样,所以我建议你在WPF中进行视频播放和在你的winforms应用程序中托管。 (我刚刚使用@Callums inkcanvas建议测试它,它就像一个魅力)

I just tested drawing over the wmp using a transparent panel and its doesn't behave as my 3rd party control did,so I suggest you do the video playing bit in WPF and host that in your winforms app. (I just tested that too using @Callums inkcanvas suggestion and it works like a charm)

这篇关于在C#中绘制视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆