Beispiel #1
0
 private static byte[] SendFullFrame()
 {
     using (var memoryStream = new MemoryStream())
     {
         using (var writer = new BinaryWriter(memoryStream))
         {
             var bounds = Screen.PrimaryScreen.Bounds;
             writer.Write(bounds.Bottom);
             writer.Write(bounds.Right);
             var image = CopyScreen.CaptureDesktop();
             //Okay the image is null
             if (image == null)
             {
                 //Lets try resetting the thread
                 var setCurrent = Desktop.SetCurrent(lastDesktopInput);
                 if (setCurrent)
                 {
                     //if the image is still null, send a frame so we don't break the whole screen share instance.
                     image = CopyScreen.CaptureDesktop();
                     if (image == null)
                     {
                         var bmp = new Bitmap(bounds.Width, bounds.Height);
                         using (var gfx = Graphics.FromImage(bmp))
                             using (var brush = new SolidBrush(Color.FromArgb(67, 75, 99)))
                             {
                                 gfx.FillRectangle(brush, 0, 0, bounds.Width, bounds.Height);
                             }
                         image = bmp;
                     }
                 }
             }
             var imageBytes = ImageToByte(image, true);
             writer.Write(imageBytes.Length);
             writer.Write(imageBytes);
             return(memoryStream.ToArray());
         }
     }
 }
Beispiel #2
0
        private static byte[] SendCleanFrame()
        {
            var image = CopyScreen.CaptureDesktop();

            return(image == null ? new byte[0] : ImageToByte(image, true));
        }