public override void SendScreenshot(Boolean fullscreen) { SwitchToInputDesktop(); byte[] image = new byte[] { }; var bmpScreenshot = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb); // Create a graphics object from the bitmap. //var img = _ScreenCapture.GetScreen(new Size(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height)); var gfxScreenshot = Graphics.FromImage(bmpScreenshot); // Take the screenshot from the upper left corner to the right bottom corner. gfxScreenshot.CopyFromScreen(System.Windows.Forms.Screen.PrimaryScreen.Bounds.X, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); var stream = new MemoryStream(); bmpScreenshot.Save(stream, ImageFormat.Png); ResponseScreenshotMessage rs = new ResponseScreenshotMessage(); rs.Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds; rs.Fullscreen = true; rs.HostSystemId = HostManager.SystemId; /*using (var msout = new MemoryStream()) * { * unsafe * { * fixed (byte* datb = img.Data) * { * using (Bitmap image = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width * 4, PixelFormat.Format32bppRgb, new IntPtr(datb))) * { * image.Save(msout, ImageFormat.Png); * rs.Image = msout.ToArray(); * * } * } * } * }*/ rs.Image = stream.ToArray(); foreach (var ID in ConnectedClients) { rs.ClientSystemId = ID; HostManager.sendMessage(rs); } }
public override void SendScreenshot(Boolean fullscreen) { Image im = OsXCapture(true); ResponseScreenshotMessage rs = new ResponseScreenshotMessage(); rs.Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds; rs.Fullscreen = true; rs.HostSystemId = HostManager.SystemId; var msout = new MemoryStream(); im.Save(msout, ImageFormat.Png); rs.Image = msout.ToArray(); foreach (var ID in ConnectedClients) { rs.ClientSystemId = ID; HostManager.sendMessage(rs); } }
public override void SendScreenshot(Boolean fullscreen) { f.WriteLine("SendScreenshot" + fullscreen); var stream = new System.IO.MemoryStream(); if (MirrorDriver.State != DesktopMirror.MirrorState.Running) { f.WriteLine("StateNotRunning"); stream = new System.IO.MemoryStream(); // Most likely first time // Start the mirror driver f.WriteLine("To Load"); MirrorDriver.Load(); f.WriteLine("To Connect"); MirrorDriver.Connect(); f.WriteLine("To Start"); MirrorDriver.Start(); Bitmap screenshot = MirrorDriver.GetScreen(); screenshot.Save(stream, ImageFormat.Png); ResponseScreenshotMessage rs = new ResponseScreenshotMessage(); rs.Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds; rs.HostSystemId = HostManager.SystemId; rs.Fullscreen = true; rs.Image = stream.ToArray(); foreach (var ID in ConnectedClients) { rs.ClientSystemId = ID; HostManager.sendMessage(rs); } } else if (MirrorDriver.State == DesktopMirror.MirrorState.Running) { // Send them the list of queued up changes var regions = (List <System.Drawing.Rectangle>)GetOptimizedRectangleRegions(); Bitmap screenshot = MirrorDriver.GetScreen(); f.WriteLine("StateRunning"); if (fullscreen) { MirrorDriver.Stop(); MirrorDriver.Start(); screenshot.Save(stream, ImageFormat.Png); this.DesktopChanges.Clear(); ResponseScreenshotMessage rs = new ResponseScreenshotMessage(); rs.Fullscreen = true; rs.Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds; rs.HostSystemId = HostManager.SystemId; rs.Image = stream.ToArray(); foreach (var ID in ConnectedClients) { rs.ClientSystemId = ID; HostManager.sendMessage(rs); } } for (int i = 0; i < regions.Count; i++) { if (regions[i].IsEmpty) { continue; } Bitmap regionShot = null; try { regionShot = screenshot.Clone(regions[i], PixelFormat.Format16bppRgb565); } catch (OutOfMemoryException ex) { } stream = new System.IO.MemoryStream(); regionShot.Save(stream, ImageFormat.Png); ResponseScreenshotMessage rs = new ResponseScreenshotMessage(); rs.Bounds = regions[i]; rs.HostSystemId = HostManager.SystemId; rs.Image = stream.ToArray(); foreach (var ID in ConnectedClients) { rs.ClientSystemId = ID; HostManager.sendMessage(rs); } } } }