how to solve this OnPaint problem ? ( about remote screen transmit )

  • Thread starter ΢ÈíÐÂÎÅ×é
  • Start date
Î

΢ÈíÐÂÎÅ×é

i want to abtain remote screen capture on the pc in LAN.
i was suggested to transmit the changed parts only to save the bandwidth.
so i divide the screen into 10*10 parts. and now , i need to display the
remote screen on my own form. my method is use this:

Graphics c = this.createGraphics();
c.drawImage(imageparts,xcoodinary,ycoodinary);// imageparts is ONE part
// of the screen (1/100)

whenever i receive a imageparts, i use the code above to draw the changed
screen parts on a FORM. the code seems to work well.In the first time,i
should call this code 100 times to get the original screen.after then , i
could only call this code several times.

but now ,when the FORM is changed or covered by other windows , with the
repaint result ,the image disappeared or changed into a wrong display.

So i should put the code above into OnPaint method. but the code above only
redraws the changed parts of the remote screen, the others disappeared.

How can i redraw the previous unchanged image already on the FORM ? OR are
there other methods to solve this problem ?

THX!
 
S

Scatropolis

I found this a little while ago and haven't used anything else since. I'm
pretty sure this is what vb6 used for autoredraw but since you control the
refresh it can be a lot faster.

pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
Image img = pictureBox1.Image;
Graphics g = Graphics.FromImage(img);
g.drawImage(imageparts,xcoodinary,ycoodinary);
pictureBox1.Image = img;

You can play around with that if you need, but that's the meat of it.
 
J

Jon Skeet [C# MVP]

΢ÈíÐÂÎÅ×é said:
i want to abtain remote screen capture on the pc in LAN.
i was suggested to transmit the changed parts only to save the bandwidth.
so i divide the screen into 10*10 parts. and now , i need to display the
remote screen on my own form. my method is use this:

Graphics c = this.createGraphics();
c.drawImage(imageparts,xcoodinary,ycoodinary);// imageparts is ONE part
// of the screen (1/100)

whenever i receive a imageparts, i use the code above to draw the changed
screen parts on a FORM. the code seems to work well.In the first time,i
should call this code 100 times to get the original screen.after then , i
could only call this code several times.

but now ,when the FORM is changed or covered by other windows , with the
repaint result ,the image disappeared or changed into a wrong display.

So i should put the code above into OnPaint method. but the code above only
redraws the changed parts of the remote screen, the others disappeared.

How can i redraw the previous unchanged image already on the FORM ? OR are
there other methods to solve this problem ?

You'll need to store all of the 100 parts in memory, and redraw
whichever bits of the screen are being repainted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top