资源简介
VFW全称为Video for Windows,是微软提供的,内嵌windows系统。用C#封装的视频类和控件。简单,方便使用。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace MyWebcam
{
public class VideoAPI
{
//视频调用API
[DllImport(“avicap32.dll“)]
public static extern IntPtr capCreateCaptureWindow(byte[] strWindowName int dwstyle int x int y int width int height IntPtr hwdParent int nID);
[DllImport(“avicap32.dll“)]
public static extern bool capGetDriverDescription(short wDriver byte[] lpszName int cbName byte[] lpszVer int cbVer);
[DllImport(“User32.dll“)]
public static extern bool SendMessage(IntPtr hWnd int wMsg bool wParam int lParam);
[DllImport(“User32.dll“)]
public static extern bool SendMessage(IntPtr hWnd int wMsg short wParam int lParam);
[DllImport(“User32.dll“)]
public static extern bool SendMessage(IntPtr hWnd int wMsg int wParam string lParam);
[DllImport(“Kernel32.dll“)]
public static extern bool CloseHandle(IntPtr hobject);
//常量
public const int WM_USER = 0x400;
public const int WS_CHILD = 0x40000000;
public const int WS_VISIBLE = 0x10000000;
public const int SWP_NOMOVE = 0x2;
public const int SWP_NOZORDER = 0x4;
public const int WM_CAP_DRIVER_CONNECT = WM_USER + 10;
public const int WM_CAP_DRIVER_DISCONNECT = WM_USER + 11;
public const int WM_CAP_SET_CALLBACK_frame = WM_USER + 5;
public const int WM_CAP_SET_PREVIEW = WM_USER + 50;
public const int WM_CAP_SET_PREVIEWRATE = WM_USER + 52;
public const int WM_CAP_SET_VIDEOFORMAT = WM_USER + 45;
public const int WM_CAP_START = WM_USER;
public const int WM_CAP_SAVEDIB = WM_CAP_START + 25;
public const int WM_CAP_SET_SCALE = WM_USER + 53;
public const int WM_COPYTOCLIPBORAD = WM_USER + 30;
public const int WM_CAP_SEQUENCE = WM_USER + 62;
public const int WM_CAP_FILE_SET_CAPTURE_FILE = WM_USER + 20;
public const int WM_CAP_STOP = WM_USER + 68;
}
public class VideoClass
{
private IntPtr caphwnd;
private IntPtr controlhwnd;
private int height;
private int width;
private bool isstart = false;
public VideoClass()
{
}
public void Initialize(IntPtr controlhwnd int width int height)
{
this.controlhwnd = controlhwnd;
this.width = width;
this.height = height;
}
~VideoClass()
{
if (isstart)
{
this.StopWebcam();
}
}
///
/// 检查是否有视频设备
///
///
public bool CheckWebcamExist()
{
byte[] lpszName = new byte[100];
byte[] lpszVer = new byte[100
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7883 2013-09-22 09:22 VideoClass.cs
文件 2471 2013-08-20 15:55 WebCam.cs
文件 6464 2013-08-20 15:07 WebCam.Designer.cs
文件 5817 2013-08-20 15:07 WebCam.resx
评论
共有 条评论