public override Bitmap CaptureScreen()
        {
            ctx.Graphics.Clear(Color.CadetBlue);
            lock (Elements)
            {
                foreach (var element in Elements)
                {
                    element.Draw(ctx);
                }
            }

            int w = 3;
            var c = Cursor;

            ctx.Graphics.DrawEllipse(new Pen(Color.Red, 2), c.X - w, c.Y - w, w * 2, w * 2);
            return(Stuff.CloneViaCopyBytes(ctx.Bitmap));
        }
Ejemplo n.º 2
0
        public void SendImg(Bitmap bmp)
        {
            Bitmap toSend     = bmp;
            bool   deltaframe = false;

            if (LastScreen != null)
            {
                deltaframe = true;
                toSend     = Stuff.Diff(LastScreen, bmp);
            }
            LastScreen = Stuff.CloneViaCopyBytes(bmp);
            writer.WriteLine("FRAME;" + (deltaframe ? "DELTA" : "FULL"));
            writer.Flush();
            MemoryStream ms = new MemoryStream();

            toSend.Save(ms, ImageFormat.Png);

            var detid     = 0;
            int chunkSize = 1024 * 10;
            var bts       = ms.ToArray();

            for (int i = 0; i < bts.Length; i += chunkSize)
            {
                var    last = bts.Length - i;
                var    arr  = bts.Skip(i).Take(Math.Min(last, chunkSize)).ToArray();
                string str2 = "CHUNK=" + detid + ";" + bts.Length + ";" + arr.Length + ";" + i + ";";
                var    b64  = Convert.ToBase64String(arr);
                var    md5  = Stuff.CreateMD5(b64);
                str2 += b64 + ";" + md5;

                writer.WriteLine(str2);
                writer.Flush();
            }
            ms.Dispose();
            writer.WriteLine("IMGEND");
            writer.Flush();
        }