| 订阅 | 在线投稿
分享
 
 
 

偶写C#

来源:互联网  宽屏版  评论
2005-04-27 19:49:36

一段代码~视频捕捉

using System;

using System.Text;

using System.Windows.Forms;

using System.Drawing;

using System.Runtime.InteropServices;

namespace VideoCap

{

/// <summary>

/// API 的摘要说明。

/// </summary>

public class API

{

public const int WS_BORDER = 0x800000;

public const int WS_CAPTION = 0xC00000;

public const int WS_SYSMENU = 0x80000;

public const int WS_CHILD = 0x40000000;

public const int WS_VISIBLE = 0x10000000;

public const int WS_OVERLAPPED = 0x0;

public const int WS_MINIMIZEBOX = 0x20000;

public const int WS_MAXIMIZEBOX = 0x10000;

public const int WS_THICKFRAME = 0x40000;

//public const int WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX);

public const int SWP_NOMOVE = 0x2;

public const int SWP_NOSIZE = 1;

public const int SWP_NOZORDER = 0x4;

public const int HWND_BOTTOM = 1;

public const int HWND_TOPMOST = -1;

public const int HWND_NOTOPMOST = -2;

public const int SM_CYCAPTION = 4;

public const int SM_CXFRAME = 32;

public const int SM_CYFRAME = 33;

public const int WS_EX_TRANSPARENT = 0x20;

public const int GWL_STYLE = (-16);

public const int WM_USER = 0x400;

public const int WM_CAP_START = WM_USER;

public const int WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1;

public const int WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2;

public const int WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3;

public const int WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4;

public const int WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5;

public const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6;

public const int WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7;

public const int WM_CAP_GET_USER_DATA = WM_CAP_START + 8;

public const int WM_CAP_SET_USER_DATA = WM_CAP_START + 9;

public const int WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;

public const int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;

public const int WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12;

public const int WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13;

public const int WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14;

public const int WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20;

public const int WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21;

public const int WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22;

public const int WM_CAP_FILE_SAVEAS = WM_CAP_START + 23;

public const int WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24;

public const int WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25;

public const int WM_CAP_EDIT_COPY = WM_CAP_START + 30;

public const int WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35;

public const int WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36;

public const int WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41;

public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42;

public const int WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43;

public const int WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44;

public const int WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45;

public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46;

public const int WM_CAP_SET_PREVIEW = WM_CAP_START + 50;

public const int WM_CAP_SET_OVERLAY = WM_CAP_START + 51;

public const int WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52;

public const int WM_CAP_SET_SCALE = WM_CAP_START + 53;

public const int WM_CAP_GET_STATUS = WM_CAP_START + 54;

public const int WM_CAP_SET_SCROLL = WM_CAP_START + 55;

public const int WM_CAP_GRAB_FRAME = WM_CAP_START + 60;

public const int WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61;

public const int WM_CAP_SEQUENCE = WM_CAP_START + 62;

public const int WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63;

public const int WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64;

public const int WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65;

public const int WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66;

public const int WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67;

public const int WM_CAP_STOP = WM_CAP_START + 68;

public const int WM_CAP_ABORT = WM_CAP_START + 69;

public const int WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70;

public const int WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71;

public const int WM_CAP_SINGLE_FRAME = WM_CAP_START + 72;

public const int WM_CAP_PAL_OPEN = WM_CAP_START + 80;

public const int WM_CAP_PAL_SAVE = WM_CAP_START + 81;

public const int WM_CAP_PAL_PASTE = WM_CAP_START + 82;

public const int WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83;

public const int WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84;

// Following added post VFW 1.1

public const int WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85;

// Defines end of the message range

public const int WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL;

public API()

{

//

// TODO: 在此处添加构造函数逻辑

//

}

private const string avicap = "avicap32.dll";

// WaveOut calls

[DllImport(avicap)]

public static extern int capCreateCaptureWindow(string lpszWindowName,int dwStyle,int x,int y,int nWidth,int nHeight,IntPtr hWndParent, int nID);

[DllImport(avicap)]

public static extern bool capGetDriverDescription(int wDriver,StringBuilder lpszName ,int cbName,StringBuilder lpszVer,int cbVer);

[DllImport("User32.dll",EntryPoint="SendMessage")]

public static extern int SendMessage(

int hWnd, // handle to destination window

int Msg, // message

int wParam, // first message parameter

int lParam // second message

);

[DllImport("User32.dll",EntryPoint="SendMessage")]

public static extern int SendMessageS(

int hWnd, // handle to destination window

int Msg, // message

int wParam, // first message parameter

string lParam // second message

);

[DllImport("User32.dll",EntryPoint="SendMessage")]

public static extern int SendMessagePtr(

int hWnd, // handle to destination window

int Msg, // message

int wParam, // first message parameter

out CAPDRIVERCAPS lParam // second message

);

//Declare Function capCreateCaptureWindowA Lib "avicap32.dll" ( ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal x As Long,

//ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Integer, ByVal hWndParent As Long, ByVal nID As Long) As Long

//Declare Function capGetDriverDescriptionA Lib "avicap32.dll" ( ByVal wDriver As Integer, ByVal lpszName As String,

//ByVal cbName As Long, ByVal lpszVer As String, ByVal cbVer As Long) As Boolean

}

public struct CAPDRIVERCAPS

{

public int wDeviceIndex ; // Driver index in system.ini

public int fHasOverlay ; // Can device overlay?

public int fHasDlgVideoSource ; // Has Video source dlg?

public int fHasDlgVideoFormat ; // Has Format dlg?

public int fHasDlgVideoDisplay ; // Has External out dlg?

public int fCaptureInitialized ; // Driver ready to capture?

public int fDriverSuppliesPalettes ; // Can driver make palettes?

public int hVideoIn ; // Driver In channel

public int hVideoOut ; // Driver Out channel

public int hVideoExtIn ; // Driver Ext In channel

public int hVideoExtOut ; // Driver Ext Out channel

}

}

一段代码~视频捕捉 using System; using System.Text; using System.Windows.Forms; using System.Drawing; using System.Runtime.InteropServices; namespace VideoCap { /// <summary> /// API 的摘要说明。 /// </summary> public class API { public const int WS_BORDER = 0x800000; public const int WS_CAPTION = 0xC00000; public const int WS_SYSMENU = 0x80000; public const int WS_CHILD = 0x40000000; public const int WS_VISIBLE = 0x10000000; public const int WS_OVERLAPPED = 0x0; public const int WS_MINIMIZEBOX = 0x20000; public const int WS_MAXIMIZEBOX = 0x10000; public const int WS_THICKFRAME = 0x40000; //public const int WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX); public const int SWP_NOMOVE = 0x2; public const int SWP_NOSIZE = 1; public const int SWP_NOZORDER = 0x4; public const int HWND_BOTTOM = 1; public const int HWND_TOPMOST = -1; public const int HWND_NOTOPMOST = -2; public const int SM_CYCAPTION = 4; public const int SM_CXFRAME = 32; public const int SM_CYFRAME = 33; public const int WS_EX_TRANSPARENT = 0x20; public const int GWL_STYLE = (-16); public const int WM_USER = 0x400; public const int WM_CAP_START = WM_USER; public const int WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1; public const int WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2; public const int WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3; public const int WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4; public const int WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5; public const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6; public const int WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7; public const int WM_CAP_GET_USER_DATA = WM_CAP_START + 8; public const int WM_CAP_SET_USER_DATA = WM_CAP_START + 9; public const int WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10; public const int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11; public const int WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12; public const int WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13; public const int WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14; public const int WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20; public const int WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21; public const int WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22; public const int WM_CAP_FILE_SAVEAS = WM_CAP_START + 23; public const int WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24; public const int WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25; public const int WM_CAP_EDIT_COPY = WM_CAP_START + 30; public const int WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35; public const int WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36; public const int WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41; public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42; public const int WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43; public const int WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44; public const int WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45; public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46; public const int WM_CAP_SET_PREVIEW = WM_CAP_START + 50; public const int WM_CAP_SET_OVERLAY = WM_CAP_START + 51; public const int WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52; public const int WM_CAP_SET_SCALE = WM_CAP_START + 53; public const int WM_CAP_GET_STATUS = WM_CAP_START + 54; public const int WM_CAP_SET_SCROLL = WM_CAP_START + 55; public const int WM_CAP_GRAB_FRAME = WM_CAP_START + 60; public const int WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61; public const int WM_CAP_SEQUENCE = WM_CAP_START + 62; public const int WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63; public const int WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64; public const int WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65; public const int WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66; public const int WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67; public const int WM_CAP_STOP = WM_CAP_START + 68; public const int WM_CAP_ABORT = WM_CAP_START + 69; public const int WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70; public const int WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71; public const int WM_CAP_SINGLE_FRAME = WM_CAP_START + 72; public const int WM_CAP_PAL_OPEN = WM_CAP_START + 80; public const int WM_CAP_PAL_SAVE = WM_CAP_START + 81; public const int WM_CAP_PAL_PASTE = WM_CAP_START + 82; public const int WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83; public const int WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84; // Following added post VFW 1.1 public const int WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85; // Defines end of the message range public const int WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL; public API() { // // TODO: 在此处添加构造函数逻辑 // } private const string avicap = "avicap32.dll"; // WaveOut calls [DllImport(avicap)] public static extern int capCreateCaptureWindow(string lpszWindowName,int dwStyle,int x,int y,int nWidth,int nHeight,IntPtr hWndParent, int nID); [DllImport(avicap)] public static extern bool capGetDriverDescription(int wDriver,StringBuilder lpszName ,int cbName,StringBuilder lpszVer,int cbVer); [DllImport("User32.dll",EntryPoint="SendMessage")] public static extern int SendMessage( int hWnd, // handle to destination window int Msg, // message int wParam, // first message parameter int lParam // second message ); [DllImport("User32.dll",EntryPoint="SendMessage")] public static extern int SendMessageS( int hWnd, // handle to destination window int Msg, // message int wParam, // first message parameter string lParam // second message ); [DllImport("User32.dll",EntryPoint="SendMessage")] public static extern int SendMessagePtr( int hWnd, // handle to destination window int Msg, // message int wParam, // first message parameter out CAPDRIVERCAPS lParam // second message ); //Declare Function capCreateCaptureWindowA Lib "avicap32.dll" ( ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal x As Long, //ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Integer, ByVal hWndParent As Long, ByVal nID As Long) As Long //Declare Function capGetDriverDescriptionA Lib "avicap32.dll" ( ByVal wDriver As Integer, ByVal lpszName As String, //ByVal cbName As Long, ByVal lpszVer As String, ByVal cbVer As Long) As Boolean } public struct CAPDRIVERCAPS { public int wDeviceIndex ; // Driver index in system.ini public int fHasOverlay ; // Can device overlay? public int fHasDlgVideoSource ; // Has Video source dlg? public int fHasDlgVideoFormat ; // Has Format dlg? public int fHasDlgVideoDisplay ; // Has External out dlg? public int fCaptureInitialized ; // Driver ready to capture? public int fDriverSuppliesPalettes ; // Can driver make palettes? public int hVideoIn ; // Driver In channel public int hVideoOut ; // Driver Out channel public int hVideoExtIn ; // Driver Ext In channel public int hVideoExtOut ; // Driver Ext Out channel } }
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
王朝网络微信公众号
微信扫码关注本站公众号wangchaonetcn
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有