public static byte[] CaptureCameraAsJPEG(WinformDVRControlControl dvrControl) { Image image = null; if (dvrControl.InvokeRequired) { GetControlAsImage getControlAsImage = new GetControlAsImage(dvrControl.DrawToImage); image = frmMain.Instance.Invoke(getControlAsImage) as Image; } else { image = dvrControl.DrawToImage(); } MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); return(ms.ToArray()); }
private void Form1_Load(object sender, EventArgs e) { WebApp.Start <HttpServerStartup>("http://+:" + ConfigurationManager.AppSettings["HTTP_PORT"]); for (int i = 1; i <= 4; i++) { var dvr = new WinformDVRControlControl() { Host = ConfigurationManager.AppSettings["DVR_IP"], Port = Int32.Parse(ConfigurationManager.AppSettings["DVR_PORT"]), Username = ConfigurationManager.AppSettings["DVR_USERNAME"], Password = ConfigurationManager.AppSettings["DVR_PASSWORD"], Channel = i, Width = Int32.Parse(ConfigurationManager.AppSettings["IMG_WIDTH"]), Height = Int32.Parse(ConfigurationManager.AppSettings["IMG_HEIGHT"]) }; dvr.Connect(); dvr.PlayStream(); flowLayoutPanel1.Controls.Add(dvr); } this.Height = Int32.Parse(ConfigurationManager.AppSettings["IMG_HEIGHT"]) * 2 + 50; this.Width = Int32.Parse(ConfigurationManager.AppSettings["IMG_WIDTH"]) * 2 + 50; }
private void Form1_Load(object sender, EventArgs e) { WebApp.Start<HttpServerStartup>("http://+:" + ConfigurationManager.AppSettings["HTTP_PORT"]); for (int i = 1; i <= 4; i++) { var dvr = new WinformDVRControlControl() { Host = ConfigurationManager.AppSettings["DVR_IP"], Port = Int32.Parse(ConfigurationManager.AppSettings["DVR_PORT"]), Username = ConfigurationManager.AppSettings["DVR_USERNAME"], Password = ConfigurationManager.AppSettings["DVR_PASSWORD"], Channel = i, Width = Int32.Parse(ConfigurationManager.AppSettings["IMG_WIDTH"]), Height = Int32.Parse(ConfigurationManager.AppSettings["IMG_HEIGHT"]) }; dvr.Connect(); dvr.PlayStream(); flowLayoutPanel1.Controls.Add(dvr); } this.Height = Int32.Parse(ConfigurationManager.AppSettings["IMG_HEIGHT"]) * 2 + 50; this.Width = Int32.Parse(ConfigurationManager.AppSettings["IMG_WIDTH"]) * 2 + 50; }
public static byte[] CaptureCameraAsJPEG(WinformDVRControlControl dvrControl) { Image image = null; if (dvrControl.InvokeRequired) { GetControlAsImage getControlAsImage = new GetControlAsImage(dvrControl.DrawToImage); image = frmMain.Instance.Invoke(getControlAsImage) as Image; } else { image = dvrControl.DrawToImage(); } MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); return ms.ToArray(); }