I\'m working on a screen sharing project ,and i recieve a small blocks of image from a Socket
constantly and need to update them on a certain initial dekstop bitmap
If you just need to draw on top of the canvas, you can draw the initial image just once and then use CreateGraphics()
and DrawImage
to update the content:
ReadData();
initial = bufferToJpeg();
pictureBox1.Image = initial;
var graphics = pictureBox1.CreateGraphics();
while (true)
{
int pos = ReadData();
Bitmap block = bufferToJpeg();
graphics.DrawImage(block, BlockX(), BlockY());
}
I'll update the answer with a performance comparison as I'm not convinced this will give any major benefit; it will, at least, avoid a double DrawImage though.