C# avicap32.dll win7录像时在视频画面的固定位置画一个圆圈,如下图所示:请给出代码例子!谢谢

C#打开摄像头抓取照片然后退出 - 开源中国社区
当前访客身份:游客 [
当前位置:
发布于 日 14时,
其实就是摄像头在后台抓个图,可以用于监控
代码片段(2)
1.&[代码][C#]代码&&&&
using System.Collections.G
using System.T
using System.D
namespace MyVideoService
class Program
static void Main(string[] args)
cVideo video = new cVideo(Process.GetCurrentProcess().MainWindowHandle, 379, 316);
video.StartWebCam();
video.GrabImage(Process.GetCurrentProcess().MainWindowHandle, "d:\\b.jpg");
video.CloseWebcam();
2.&[代码][C#]代码&&&&
using System.Collections.G
using System.T
using System.Runtime.InteropS
using System.Drawing.I
using System.D
using System.IO;
namespace MyVideoService
public class VideoAPI
//视频API类
视频API调用
[DllImport("avicap32.dll")]
public static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, int nID);
[DllImport("avicap32.dll")]
public static extern bool capGetDriverDescriptionA(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);
public const int WM_USER = 0x400;
public const int WS_CHILD = 0x;
public const int WS_VISIBLE = 0x;
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 class cVideo
private IntPtr lwndC;
//保存无符号句柄
private IntPtr mControlP //保存管理指示器
private int mW
private int mH
public cVideo(IntPtr handle, int width, int height)
mControlPtr = //显示视频控件的句柄
//视频宽度
//视频高度
/// &summary&
/// 打开视频设备
/// &/summary&
public void StartWebCam()
byte[] lpszName = new byte[100];
byte[] lpszVer = new byte[100];
VideoAPI.capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100);
this.lwndC = VideoAPI.capCreateCaptureWindowA(lpszName, VideoAPI.WS_CHILD | VideoAPI.WS_VISIBLE, 0, 0, mWidth, mHeight, mControlPtr, 0);
if (VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_DRIVER_CONNECT, 0, 0))
VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_SET_PREVIEWRATE, 100, 0);
VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_SET_PREVIEW, true, 0);
/// &summary&
/// 关闭视频设备
/// &/summary&
public void CloseWebcam()
VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_DRIVER_DISCONNECT, 0, 0);
&/summary&
name="path"&要保存jpeg文件的路径&/param&
public void GrabImage(IntPtr hWndC, string path)
IntPtr hBmp = Marshal.StringToHGlobalAnsi(path);
VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_SAVEDIB, 0, hBmp.ToInt32());
Bitmap image = new Bitmap(path);
if (path.Contains("bmp"))
image.Save(path.Replace("bmp", "jpg"), ImageFormat.Jpeg);
image.Dispose();
if (System.IO.File.Exists(path))
System.IO.File.Delete(path);
catch (System.IO.IOException e)
image.Save(path, ImageFormat.Jpeg);
image.Dispose();
开源中国-程序员在线工具:
相关的代码(16)
9回/4418阅
23回/7294阅
7回/1644阅
3回/5907阅
4回/4738阅
2回/4722阅
很明显是用来做坏事的
2楼:北洋螃蟹 发表于
引用来自“杨同学”的评论很明显是用来做坏事的你懂的~
3楼:did0602 发表于
好东西,有空研究一下
4楼:司谋客 发表于
必须学习。。。
5楼:帅哥阿亮 发表于
试了一下,能编译,但是运行没有效果,没有开启视频,也没有保存到图片
6楼:web天空 发表于
编译时Bitmap一直报path参数无效错误
7楼:马知常 发表于
很棒啊。 特别是存图片参数。
8楼:冰点火花 发表于
引用来自“帅哥阿亮”的评论试了一下,能编译,但是运行没有效果,没有开启视频,也没有保存到图片我这里运行也不行
9楼:--路边小草-- 发表于
vs2010完美编译通过,而且我的电脑也能完美运行,在D盘b.jpg能找到照片,但是就是安全软件会报有程序在调用摄像头(看来安全软件还是有点用的)。
10楼:--路边小草-- 发表于
补充:在xp下完美运行,在win7下运行
报path参数无效错误,不知道是系统原因,还是摄像头不同的原因。
11楼:SUNFLAY 发表于
我只是路过的
12楼:贝儿 发表于
引用来自“--路边小草--”的评论vs2010完美编译通过,而且我的电脑也能完美运行,在D盘b.jpg能找到照片,但是就是安全软件会报有程序在调用摄像头(看来安全软件还是有点用的)。你说的安全软件是360吗?
13楼:yl_军A00001 发表于
开源从代码分享开始
北洋螃蟹的其它代码1.关于avicap32.dll基本概念
VFW(Video For Window)技术是Microsoft公司为开发Windows平台下的视频应用程序提供的软件工具包,提供了一系列应用程序编程接口(API),用户可以通过这些接口很 方便地实现视频捕获、视频编辑及视频播放等通用功能,还可利用回调函数开发比较复杂的视频应用程序。该技术的特点是播放视频时不需要专用的硬件设备,而且 应用灵活,可以满足视频应用程序开发的需要。Windows操作系统自身就携带了VFW技术,系统安装时,会自动安装VFW的相关组件。
AVICAP32.DLL:包含执行视频捕获的函数,给AVI文件的I/O处理和视频,音频设备驱动程序提供一个高级接口。&MSVIDEO.DLL:包含一套特殊的DrawDib函数,用来处理程序上的视频操作。MCIAVI.DRV:包括对VFW的MCI命令解释器的驱动程序。AVIFILE.DLL:包含由标准多媒体I/O(mmio)函数提供的更高级的命令,用来访问.AVI文件。ICM:压缩管理器,用于管理的视频压缩/解压缩的编译码器。ACM:音频压缩管理器,提供与ICM相似的服务,适用于波形音频。
2.关于avicap32.dll重要函数的参数的介绍
(1)capCreateCaptureWindow函数
该函数用于创建一个视频捕捉窗口。语法如下:
&&&&&&& [DllImport("avicap32.dll")]
&&&&&&& public static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, int nID);
参数说明如下。
l &&& lpszWindowName:标识窗口的名称。
l &&& dwStyle:标识窗口风格。
l &&& x、y:标识窗口的左上角坐标。
l &&& nWidth、nHeight:标识窗口的宽度和高度。
l &&& hWnd:标识父窗口句柄。
l &&& nID:标识窗口ID。
l &&& 返回值:视频捕捉窗口句柄。
(2)SendMessage函数
用于向Windows系统发送消息机制。
[DllImport("User32.dll")]
private static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
参数说明如下。
l &&& hWnd:窗口句柄。
l &&& wMsg:将要发送的消息。
l &&& wParam、lParam:消息的参数,每个消息都有两个参数,参数设置由发送的消息而定。
using System.Runtime.InteropS
using System.D
using System.T
namespace AVI
public class AviCapture
#region 导入API函数
[DllImport("avicap32.dll")]//包含了执行视频捕获的函数,它给AVI文件I/O和视频、音频设备驱动程序提供一个高级接口
public static extern IntPtr capCreateCaptureWindow(string lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hwndParent, int nID);
/************参数说明*************
* 函数:capCreateCaptureWindow
* lpszWindowName:标识窗口的名称
* dwStyle:标识窗口风格
* x、y:标识窗口的左上角坐标
* nWidth、nHeight:标识窗口的宽度和高度
* hWnd:标识父窗口句柄
* nID:标识窗口ID
* 返回值:视频捕捉窗口句柄。
********************************/
[DllImport("AVICAP32.dll", CharSet = CharSet.Unicode)]
public static extern bool capGetDriverDescription(int wDriverIndex, StringBuilder lpszName, int cbName, StringBuilder 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, int lParam);
[DllImport("User32.dll")]
public static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, FrameEventHandler lParam);
[DllImport("User32.dll")]
public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, ref BITMAPINFO lParam);
[DllImport("User32.dll")]
public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, ref CAPDRIVERCAPS lParam);
[DllImport("User32.dll")]
public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, ref CAPTUREPARMS lParam);
[DllImport("User32.dll")]
public static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, ref CAPSTATUS lParam);
[DllImport("User32.dll")]
public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
[DllImport("avicap32.dll")]
public static extern int capGetVideoFormat(IntPtr hWnd, IntPtr psVideoFormat, int wSize);
#endregion
#region 消息常量(向窗口发送消息的指令)
//消息常量 --------------------------------------------
public const int WM_START = 0x400;
//此并非摄像头消息0x400表示的就是1024
public const int WS_CHILD = 0x;
public const int WS_VISIBLE = 0x;
public const int SWP_NOMOVE = 0x2;
public const int SWP_NOZORDER = 0x4;
public const int WM_CAP_GET_CAPSTREAMPTR = WM_START + 1;
public const int WM_CAP_SET_CALLBACK_ERROR = WM_START + 2;//设置收回错误
public const int WM_CAP_SET_CALLBACK_STATUS = WM_START + 3;//设置收回状态
public const int WM_CAP_SET_CALLBACK_YIELD = WM_START + 4;//设置收回出产
public const int WM_CAP_SET_CALLBACK_FRAME = WM_START + 5;//设置收回结构
public const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_START + 6;//设置收回视频流
public const int WM_CAP_SET_CALLBACK_WAVESTREAM = WM_START + 7;//设置收回视频波流
public const int WM_CAP_GET_USER_DATA = WM_START + 8;//获得使用者数据
public const int WM_CAP_SET_USER_DATA = WM_START + 9;//设置使用者数据
public const int WM_CAP_DRIVER_CONNECT = WM_START + 10;//驱动程序连接
public const int WM_CAP_DRIVER_DISCONNECT = WM_START + 11;//断开启动程序连接
public const int WM_CAP_DRIVER_GET_NAME = WM_START + 12;//获得驱动程序名字
public const int WM_CAP_DRIVER_GET_VERSION = WM_START + 13;//获得驱动程序版本
public const int WM_CAP_DRIVER_GET_CAPS = WM_START + 14;//获得驱动程序帽子
public const int WM_CAP_FILE_SET_CAPTURE_FILE = WM_START + 20;//设置捕获文件
public const int WM_CAP_FILE_GET_CAPTURE_FILE = WM_START + 21;//获得捕获文件
public const int WM_CAP_FILE_ALLOCATE = WM_START + 22;//分派文件
public const int WM_CAP_FILE_SAVEAS = WM_START + 23;//另存文件为
public const int WM_CAP_FILE_SET_INFOCHUNK = WM_START + 24;//设置开始文件
public const int WM_CAP_FILE_SAVEDIB = WM_START + 25;//保存文件
public const int WM_CAP_EDIT_COPY = WM_START + 30;//编辑复制
public const int WM_CAP_SET_AUDIOFORMAT = WM_START + 35;//设置音频格式
public const int WM_CAP_GET_AUDIOFORMAT = WM_START + 36;//捕获音频格式
public const int WM_CAP_DLG_VIDEOFORMAT = WM_START + 41;//1065 打开视频格式设置对话框
public const int WM_CAP_DLG_VIDEOSOURCE = WM_START + 42;//1066 打开属性设置对话框,设置对比度亮度等
public const int WM_CAP_DLG_VIDEODISPLAY = WM_START + 43;//1067 打开视频显示
public const int WM_CAP_GET_VIDEOFORMAT = WM_START + 44;//1068 获得视频格式
public const int WM_CAP_SET_VIDEOFORMAT = WM_START + 45;//1069 设置视频格式
public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_START + 46;//1070 打开压缩设置对话框
public const int WM_CAP_SET_PREVIEW = WM_START + 50;//设置预览
public const int WM_CAP_SET_OVERLAY = WM_START + 51;//设置覆盖
public const int WM_CAP_SET_PREVIEWRATE = WM_START + 52;//设置预览比例
public const int WM_CAP_SET_SCALE = WM_START + 53;//设置刻度
public const int WM_CAP_GET_STATUS = WM_START + 54;//获得状态
public const int WM_CAP_SET_SCROLL = WM_START + 55;//设置卷
public const int WM_CAP_GRAB_FRAME = WM_START + 60;//逮捕结构
public const int WM_CAP_GRAB_FRAME_NOSTOP = WM_START + 61;//停止逮捕结构
public const int WM_CAP_SEQUENCE = WM_START + 62;//次序
public const int WM_CAP_SEQUENCE_NOFILE = WM_START + 63;//使用WM_CAP_SEUENCE_NOFILE消息(capCaptureSequenceNoFile宏),可以不向磁盘文件写入数据。该消息仅在配合回调函数时有用,它允许你的应用程序直接使用音视频数据。
public const int WM_CAP_SET_SEQUENCE_SETUP = WM_START + 64;//设置安装次序
public const int WM_CAP_GET_SEQUENCE_SETUP = WM_START + 65;//获得安装次序
public const int WM_CAP_SET_MCI_DEVICE = WM_START + 66;//设置媒体控制接口
public const int WM_CAP_GET_MCI_DEVICE = WM_START + 67;//获得媒体控制接口
public const int WM_CAP_STOP = WM_START + 68;//停止
public const int WM_CAP_ABORT = WM_START + 69;//异常中断
public const int WM_CAP_SINGLE_FRAME_OPEN = WM_START + 70;//打开单一的结构
public const int WM_CAP_SINGLE_FRAME_CLOSE = WM_START + 71;//关闭单一的结构
public const int WM_CAP_SINGLE_FRAME = WM_START + 72;//单一的结构
public const int WM_CAP_PAL_OPEN = WM_START + 80;//打开视频
public const int WM_CAP_PAL_SAVE = WM_START + 81;//保存视频
public const int WM_CAP_PAL_PASTE = WM_START + 82;//粘贴视频
public const int WM_CAP_PAL_AUTOCREATE = WM_START + 83; //自动创造
public const int WM_CAP_PAL_MANUALCREATE = WM_START + 84;//手动创造
public const int WM_CAP_SET_CALLBACK_CAPCONTROL = WM_START + 85;// 设置收回的错误
#endregion 消息常量
#region 结构体
/*********VideoHdr 结构体*********
* 定义了视频数据块的头信息,
* 在编写回调函数时常用到其数据成员lpData(指向数据缓存的指针)和dwBufferLength(数据缓存的大小)。
* 视频帧到缓存的捕获则需要应用回调函数和相应的数据块结构 VIDEOHDR
*******************************/
[StructLayout(LayoutKind.Sequential)]
public struct VIDEOHDR
public IntPtr lpD
/* 指向数据缓存的指针 */
public int dwBufferL
/* 数据缓存的大小 */
public int dwBytesU
/* Bytes actually used */
public int dwTimeC
/* Milliseconds from start of stream */
public int dwU
/* for client's use */
public int dwF
/* assorted flags (see defines) */
public int dwR
/* reserved for driver */
/*********BitmapInfoHeader 结构体*********
* BitmapInfoHeader定义了位图的头部信息
****************************************/
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFOHEADER
public int biS
public int biW
public int biH
public short biP
public short biBitC
public int biC
public int biSizeI
public int biXPelsPerM
public int biYPelsPerM
public int biClrU
public int biClrI
/*********BitmapInfo 结构体*********
* BitmapInfo 定义了位图信息
***********************************/
[StructLayout(LayoutKind.Sequential)]
public struct BITMAPINFO
public BITMAPINFOHEADER bmiH
public int bmiC
/*********CAPTUREPARMS 结构体*********
* CAPTUREPARMS 包含控制视频流捕获过程的参数,如捕获帧频、指定键盘或鼠标键以终止捕获、捕获时间限制等
***********************************/
[StructLayout(LayoutKind.Sequential)]
public struct CAPTUREPARMS
public int dwRequestMicroSecPerF
// 期望的桢播放率,以毫秒为单位,默认为66667,相当于15桢每秒。
public bool fMakeUserHitOKToC
// Show "Hit OK to cap" dlg?开始捕获标志位,如果值为真,则在开始捕获前要产生一个询问对话框,默认为假。
public uint wPercentDropForE
//所允许的最大丢桢百分比,可以从0变化到100,默认值为10。
public bool fY
/*另起线程标志位,如果为真,则程序重新启动一个线程用于视频流的捕获,默认值是假。
但是如果你是为了真,你必须要在程序中处理一些潜在的操作,因为当视频捕获时,其他操作并没有被屏蔽。*/
public int dwIndexS
// 在AVI文件中所允许的最大数目的索引项(32K)
public uint wChunkG
// AVI文件的逻辑尺寸,以字节为单位。如果值是0,则说明该尺寸渐增 在 Win32程序中无用。(2K)
public bool fUsingDOSM
// Use DOS buffers?
public uint wNumVideoR
// 所被允许分配的最大视频缓存
public bool fCaptureA
// 音频标志位,如果音频流正在捕获,则该值为真。
public uint wNumAudioR
// 最大数量的音频缓存,默认值为10。
public uint vKeyA
// 终止流捕获的虚拟键盘码,默认值为VK_ESCAPE
[MarshalAs(UnmanagedType.Bool)]
public bool fAbortLeftM
// 终止鼠标左键标志位,如果该值为真,则在流捕获过程中如果点击鼠标左键则该捕获终止,默认值为真。
public bool fAbortRightM
// Abort on right mouse?
public bool fLimitE
// 捕获操作时间限制,如果为真,则时间到了以后捕获操作终止,默认为假
public uint wTimeL
// 具体终止时间,只有 fLimitEnabled是真时.该位才有效
public bool fMCIC
// Use MCI video source?
public bool fStepMCID
// Step MCI device?MCI 设备标志。
public int dwMCIStartT
// Time to start in MS
public int dwMCIStopT
// Time to stop in MS
public bool fStepCaptureAt2x;
// Perform spatial averaging 2x
public int wStepCaptureAverageF // 当基于平均采样来创建桢时,桢的采样时间,典型值是5
public int dwAudioBufferS
// 音频缓存的尺寸,如果用默认值0,缓存尺寸是最大0.5秒,或10k字节。
public int fDisableWriteC
// Attempt to disable write cache
public int AVStreamM
//音视频同步标志。
/*********CAPDRIVERCAPS 结构体*********
* CAPDRIVERCAPS 定义了捕获驱动器的能力,如有无视频叠加能力、有无控制视频源、视频格式的对话框等
**************************************/
[StructLayout(LayoutKind.Sequential)]
public struct CAPDRIVERCAPS
[MarshalAs(UnmanagedType.U2)]
public UInt16 wDeviceI
//捕获驱动器的索引值,该值可以由0到9变化。
[MarshalAs(UnmanagedType.Bool)]
public bool fHasO
// 视频叠加标志,如果设备支持视频叠加这该位是真。
[MarshalAs(UnmanagedType.Bool)]
public bool fHasDlgVideoS
//视频资源对话框标志位,如果设备支持视频选择、控制对话框,该值为真。
[MarshalAs(UnmanagedType.Bool)]
public bool fHasDlgVideoF
//视频格式对话框标志位,如果设备支持对视频格式对话框的选择,该位真。
[MarshalAs(UnmanagedType.Bool)]
public bool fHasDlgVideoD
//视频展示对话框标志位,如果设备支持对视频捕获缓存区的重新播放,该位是真。
[MarshalAs(UnmanagedType.Bool)]
public bool fCaptureI
//捕获安装标志位,如果捕获驱动器已经成功连接,该值为真。
//[MarshalAs(UnmanagedType.Bool)]
public bool fDriverSuppliesP //驱动器调色板标志位,如果驱动器能创建调色板,则该位是真。
[MarshalAs(UnmanagedType.I4)]
public int hVideoIn;
[MarshalAs(UnmanagedType.I4)]
public int hVideoO
[MarshalAs(UnmanagedType.I4)]
public int hVideoExtIn;
[MarshalAs(UnmanagedType.I4)]
public int hVideoExtO
/*********CAPSTATUS 结构体*********
* CAPSTATUS 定义了捕获窗口的当前状态,如图像的宽、高等
**************************************/
[StructLayout(LayoutKind.Sequential)]
public struct CAPSTATUS
public int uiImageW
//图像宽度
public int uiImageH
//图像高度
public bool fLiveW
//活动窗口标记,如果窗口正以预览的方式展示图像,那么该值为真
public bool fOverlayW
//叠加窗口标志位,如果正在使用硬件叠加,则该位是真。
public bool fS
//输入所放标志位,如果窗口是正在缩放视频到客户区,那么该位是真。当使用硬件叠加时,改位无效。
public Point ptS
//被展示在窗口客户区左上角的那个象素的x、y坐标偏移量。
public bool fUsingDefaultP
//默认调色板标志位,如果捕获窗口正在使用当前默认调色板,该值为真
public bool fAudioH
// 音频硬件标志位,如果系统已经安装了音频硬件,该值为真。
public bool fCapFileE
//捕获文件标志位,如果一个捕获文件已经被创建,该值为真
public int dwCurrentVideoF
// 当前或最近流捕获过程中,所处理的桢的数目。包括丢弃的桢。
public int dwCurrentVideoFramesD//当前流捕获过程中丢弃的桢的数目。
public int dwCurrentWaveS
// # of wave samples cap'td
public int dwCurrentTimeElapsedMS;
// 从当前流捕获开始计算,程序所用的时间,以毫秒为单位。
public IntPtr hPalC
// 当前剪切板的句柄。
public bool fCapturingN
// 捕获标志位,当捕获是正在进行时,改位是真
public int dwR
// 错误返回值,当你的应用程序不支持错误回调函数时可以应用改位
public int wNumVideoA
// 被分配的视频缓存的数目。
public int wNumAudioA
// 被分配的音频缓存的数目。
#endregion
#region 基本函数
public delegate void FrameEventHandler(IntPtr lwnd, IntPtr lpVHdr);
public static object GetStructure(IntPtr ptr, ValueType structure)
return Marshal.PtrToStructure(ptr, structure.GetType());
public static object GetStructure(int ptr, ValueType structure)
return GetStructure(new IntPtr(ptr), structure);
public static void Copy(IntPtr ptr, byte[] data)
Marshal.Copy(ptr, data, 0, data.Length);
public static void Copy(int ptr, byte[] data)
Copy(new IntPtr(ptr), data);
public static int SizeOf(object structure)
return Marshal.SizeOf(structure);
#endregion
阅读(...) 评论()C#显示摄像头实时视频应该怎么做?求指导!不甚感激!
[问题点数:40分]
C#显示摄像头实时视频应该怎么做?求指导!不甚感激!
[问题点数:40分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
本帖子已过去太久远了,不再提供回复功能。private void FrameCallBacker(IntPtr lwnd, IntPtr lpVHdr)
showVideo.VIDEOHDR videoHeader = new showVideo.VIDEOHDR();
byte[] VideoD
videoHeader = (showVideo.VIDEOHDR)showVideo.GetStructure(lpVHdr, videoHeader);
//难道在这里?下面的VideoData会得到视屏信息 我想只要发送这个就可以了
VideoData = new byte[videoHeader.dwBytesUsed];//在这里赋值
showVideo.Copy(videoHeader.lpData, VideoData);
//在这里显示
if (this.RecievedFrame != null)
this.RecievedFrame(VideoData);
注释那些是我跟踪后判断的,不一定判断正确,我第一次使用API,所以很多都不清楚,我先把这个类贴出来,后面贴上窗体的代码,目的就是想让大家帮帮我:1
我是不是只需要把VideoData传过去,就可以了,如果这个思路是对的,那么,我在客户端怎么操作(这是我最想要的结果,我在客户端怎么处理,其实我还是不明白这个VideoData数组怎么保存的)2
如果还有其他的处理方式,请不吝赐教啊具体的类就在这个连接http://blog.csdn.net/zzmdegm/article/details/1915364的例二------解决方案--------------------
是这样的哥哥,首先你要知道你一次获取到一张的图片的BYTE[]的大小,还要知道这个图片的格式例如IMG什么的,然后你最好是先实现在本地将BYTE【】数组里的数据转换成你要播放的格式并显示出来。能再本地播放了,在转换成数据流发送到客户端,在客户端,循环接受一个完成的BYTE【】数组,也就是说用TCP一次发送的数据只能有1024,而你的图片可能超过1024,这怎么办?自己想想应该能解决,当你确定这个图片的数据都发送过去了以后,将这个BYTE【】转换成你想要的图片格式就行了。虽然说的不清楚希望能给点分我很穷 邪邪
------解决方案--------------------
這裡不是有現成例子和控件嗎?/products/tvideograbber/download.html
------解决方案--------------------关注了
------解决方案--------------------/sdk/multimedia-suite.htm?linkid=top更強大
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 12345678910 Copyright & &&版权所有

我要回帖

更多关于 avicap32.dll win7 的文章

 

随机推荐