Example #1
0
        public async Task SendUpdates()
        {
            Bitmap src = CaptureImage();
            int    wdt = src.Width / x, hgt = src.Height / y;

            for (int i = 0; i < y; i++)
            {
                for (int j = 0; j < x; j++)
                {
                    Rectangle r = new Rectangle(new Point(j * wdt, i * hgt), new Size(wdt, hgt));
                    sa[i, j] = src.Clone(r, src.PixelFormat);
                    if (!Ext.Compare(sa[i, j], prev[i, j]))
                    {
                        try
                        {
                            using (MemoryStream ms = new MemoryStream())
                            {
                                Ext.Resized(sa[i, j]).Save(ms, ImageFormat.Jpeg);
                                string base64 = Convert.ToBase64String(ms.ToArray());
                                if (encrypted)
                                {
                                    base64 = Ext.Encoded(base64.Substring(0, 200)) + base64.Substring(200);
                                }
                                await connection.InvokeAsync("UpdateScreen", base64, i, j, encrypted, sa[i, j].Height, sa[i, j].Width);

                                prev[i, j] = sa[i, j];
                            }
                        }
                        catch (Exception e) { MessageBox.Show(e.Message); }
                    }
                }
            }
        }