微信小程序 > 微信公开课 > 关于控制摄像头拍照代码
微信小程序,微信公开课,关于控制摄像头拍照代码

关于控制摄像头拍照代码

2019-03-12 17:02:19

微信公开课小程序热门讨论「关于控制摄像头拍照代码」最新回复-usingSystem.Runtime.InteropServices;usingSystem.Drawing.Imaging;usingSystem.Net;usingSystem.Net.Sockets;usingSystem.Threading;//视频操作privateinthHwnd;privateconstintport=2000;publicstructvideohdr_tag{publicbyte[]lpData;publicintdwBufferLength;publicintdwBytesUsed;publicintdwTimeCaptured;publicintdwUser;publicintdwFlags;publicint[]dwReserved;}publicdelegateboolCallBack(inthwnd,intlParam);///summary///必需的设计器变量。////summary//privateSystem.ComponentModel.Containercomponents=null;[DllImport(avicap32.dll,CharSet=CharSet.Ansi,SetLastError=true,ExactSpelling=true)]publicstaticexternintcapCreateCaptureWindowA([MarshalAs(UnmanagedType.VBByRefStr)]refstringlpszWindowName,intdwStyle,intx,inty,intnWidth,shortnHeight,inthWndParent,intnID);[DllImport(avicap32.dll,CharSet=CharSet.Ansi,SetLastError=true,ExactSpelling=true)]publicstaticexternboolcapGetDriverDescriptionA(shortwDriver,[MarshalAs(UnmanagedType.VBByRefStr)]refstringlpszName,intcbName,[MarshalAs(UnmanagedType.VBByRefStr)]refstringlpszVer,intcbVer);[DllImport(user32,CharSet=CharSet.Ansi,SetLastError=true,ExactSpelling=true)]publicstaticexternboolDestroyWindow(inthndw);[DllImport(user32,EntryPoint=SendMessageA,CharSet=CharSet.Ansi,SetLastError=true,ExactSpelling=true)]publicstaticexternintSendMessage(inthwnd,intwMsg,intwParam,[MarshalAs(UnmanagedType.AsAny)]objectlParam);[DllImport(user32,CharSet=CharSet.Ansi,SetLastError=true,ExactSpelling=true)]publicstaticexternintSetWindowPos(inthwnd,inthWndInsertAfter,intx,inty,intcx,intcy,intwFlags);[DllImport(vfw32.dll)]publicstaticexternstringcapVideoStreamCallback(inthwnd,videohdr_tagvideohdr_tag);[DllImport(vicap32.dll,CharSet=CharSet.Ansi,SetLastError=true,ExactSpelling=true)]publicstaticexternboolcapSetCallbackOnFrame(inthwnd,strings);privatevoidOpenCapture(){intintDevice=0;stringrefDevice=intDevice.ToString();//创建视频窗口并得到句柄hHwnd=ChatAdvanceForm.capCreateCaptureWindowA(refrefDevice,1342177280,0,0,(short)this.pnlShiPing.Width,(short)this.pnlShiPing.Height,this.pnlShiPing.Handle.ToInt32(),0);if(ChatAdvanceForm.SendMessage(hHwnd,0x40a,intDevice,0)0){ChatAdvanceForm.SendMessage(this.hHwnd,0x435,1,0);ChatAdvanceForm.SendMessage(this.hHwnd,0x434,0x42,0);ChatAdvanceForm.SendMessage(this.hHwnd,0x432,1,0);ChatAdvanceForm.SetWindowPos(this.hHwnd,1,0,0,this.pnlShiPing.Width,this.pnlShiPing.Height,6);}else{ChatAdvanceForm.DestroyWindow(this.hHwnd);}}privatevoidbtnBeginListenr_Click(objectsender,EventArgse){this.OpenCapture();}privatevoidbtnStopListenr_Click(objectsender,EventArgse){//停止视频注销视频句柄ChatAdvanceForm.SendMessage(this.hHwnd,0x40b,0,0);ChatAdvanceForm.DestroyWindow(this.hHwnd);}//截图privatevoidbtnCutPic_Click(objectsender,EventArgse){try{ChatAdvanceForm.SendMessage(this.hHwnd,0x41e,0,0);IDataObjectobj1=Clipboard.GetDataObject();if(obj1.GetDataPresent(typeof(Bitmap))){Imageimage1=(Image)obj1.GetData(typeof(Bitmap));SaveFileDialogSaveFileDialog1=newSaveFileDialog();SaveFileDialog1.FileName=DateTime.Now.ToString(yyyyMMddhhmmss);SaveFileDialog1.Filter=ImageFiles(*.JPG;*.GIF)|*.JPG;*.GIF|Allfiles(*.*)|*.*;if(SaveFileDialog1.ShowDialog()==DialogResult.OK){image1.Save(SaveFileDialog1.FileName,ImageFormat.Bmp);}}}catch{}}//当视频面板变化的时候视频窗口也跟着变化privatevoidpnlShiPing_SizeChanged(objectsender,EventArgse){//停止视频注销视频句柄ChatAdvanceForm.SendMessage(this.hHwnd,0x40b,0,0);ChatAdvanceForm.DestroyWindow(this.hHwnd);OpenCapture();}
找一下AVICap这个代码,以前查过流接口编程,跟什么型号摄像头没关系。 更多有关「关于控制摄像头拍照代码」的疑问请扫码关注微信公开课+小程序!
标签:微信公开课,小程序
微信小程序,微信公开课,关于控制摄像头拍照代码

「关于控制摄像头拍照代码」热议话题订阅

方法1:微信扫描微信公开课小程序码即可订阅热议话题「关于控制摄像头拍照代码」

方法2:微信搜索微信公开课小程序名称进入,即可订阅热议话题「关于控制摄像头拍照代码」

方法3:微信网页访问即速商店,长按识别微信公开课小程序码即可订阅热议话题「关于控制摄像头拍照代码」

微信公开课小程序热议话题「关于控制摄像头拍照代码」由微信公开课原创摘录于微信小程序商店shop.jisuapp.cn,转载请注明出处。

微信公开课热议话题「关于控制摄像头拍照代码」由微信公开课开发者向微信用户提供,并对本服务内容、数据资料及其运营行为等真实性、合法性及有效性承担全部责任。