Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- and here is the drawimage function:
- private void DrawImage(Image image)
- {
- lock (lockClosing)
- {
- //if (checkBox1.Checked)
- // MessageBox.Show("lol");
- try
- {
- if (closing) return;
- if (InvokeRequired)
- Invoke((MethodInvoker)delegate
- {
- using (Graphics gView = ts.CreateGraphics())
- gView.DrawImage(image, 0, 0, ts.Width, ts.Height);
- });
- else using (Graphics gView = ts.CreateGraphics())
- gView.DrawImage(image, 0, 0, ts.Width, ts.Height);
- }
- catch (Exception ex)
- {
- MessageBox.Show("Draw Error: " + ex.Message);
- }
- }
- }
- try
- {
- lock (ImgSync)
- {
- int type = pr.ReadInt32();
- reading the data we send from our client
- int x = pr.ReadInt32();
- int y = pr.ReadInt32();
- int width = pr.ReadInt32();
- int height = pr.ReadInt32();
- int size = pr.ReadInt32();
- byte[] chunk = pr.ReadBytes(size);
- data read done..
- using (MemoryStream imgMs = new MemoryStream(chunk))
- using (Bitmap bmpChunk = (Bitmap)Bitmap.FromStream(imgMs))
- using (Graphics screenG = Graphics.FromImage(lastImage))
- {
- screenG.DrawImage(bmpChunk, x, y, width, height);
- DrawImage(lastImage);
- DoubleBuffered = true;
- }
- chunk = null;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("screen error:" + ex.Message);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement