C # Videoapi

Source: Internet
Author: User

usingSystem;usingSystem.Runtime.InteropServices; Public classVideoapi//Video API Classes{    //Video API calls[DllImport ("Avicap32.dll")]     Public Static externIntPtr Capcreatecapturewindowa (byte[] lpszWindowName,intDwstyle,intXintYintNwidth,intNheight, IntPtr hwndparent,intNID); [DllImport ("Avicap32.dll")]     Public Static extern BOOLCapgetdriverdescriptiona ( ShortWdriver,byte[] LpszName,intCBName,byte[] Lpszver,intcbver); [DllImport ("User32.dll")]     Public Static extern BOOLSendMessage (IntPtr hWnd,intWmsg,BOOLWParam,intLParam); [DllImport ("User32.dll")]     Public Static extern BOOLSendMessage (IntPtr hWnd,intWmsg, ShortWParam,intLParam); //Constants     Public Const intWm_user =0x400;  Public Const intWs_child =0x40000000;  Public Const intWs_visible =0x10000000;  Public Const intSwp_nomove =0x2;  Public Const intSwp_nozorder =0x4;  Public Const intWm_cap_driver_connect = Wm_user +Ten;  Public Const intWm_cap_driver_disconnect = Wm_user + One;  Public Const intWm_cap_set_callback_frame = Wm_user +5;  Public Const intWm_cap_set_preview = Wm_user + -;  Public Const intWm_cap_set_previewrate = Wm_user + the;  Public Const intWm_cap_set_videoformat = Wm_user + $;  Public Const intWm_cap_start =Wm_user;  Public Const intWm_cap_savedib = Wm_cap_start + -;} Public classCvideo//Video Class{    PrivateIntPtr LWNDC;//To save an unsigned handle    PrivateIntPtr mcontrolptr;//Save Management Indicators    Private intMwidth; Private intMheight;  PublicCvideo (INTPTR handle,intWidthintheight) {Mcontrolptr= handle;//to display a handle to a video controlMwidth = width;//Video WidthMheight = height;//Video Height    }    /// <summary>    ///turn on the video device/// </summary>     Public voidStartwebcam () {byte[] LpszName =New byte[ -]; byte[] Lpszver =New byte[ -]; Videoapi.capgetdriverdescriptiona (0, LpszName, -, Lpszver, -);  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, -,0); Videoapi.sendmessage (LWNDC, Videoapi.wm_cap_set_preview,true,0); }    }    /// <summary>    ///Turn off the video device/// </summary>     Public voidClosewebcam () {videoapi.sendmessage (LWNDC, Videoapi.wm_cap_driver_disconnect,0,0); }    /// <summary>     ///Take Pictures/// </summary>     /// <param name= "path" >the path to save the BMP file</param>      Public voidGrabimage (IntPtr Hwndc,stringpath) {INTPTR hbmp=marshal.stringtohglobalansi (path); Videoapi.sendmessage (LWNDC, Videoapi.wm_cap_savedib,0, Hbmp.toint32 ()); }}

C # Videoapi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.