Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
How to draw Efficiently on Picture Box in C#
I am developing a Remoting application in C#, through which I can view the remote system over the LAN, I am facing problem in case of videos.. I am not receiving the Real Time video on the remote system. its a little bit slow. with profiler I have checked that the time is being taken on two following fuction calls
private void PlaceUpdateOnBmp(Bitmap newBitmap, int x1, int y1, int x2, int y2)
bool resChangeFlag = false;
Rectangle rect = new Rectangle(x1, y1, x2, y2);
if (Screen.AllScreens.Bounds.Width != clientScreenX / noOfScreens || Screen.AllScreens.Bounds.Height != clientScreenY)
bmp = new Bitmap(1024, 768);
g = Graphics.FromImage(bmp);
g.DrawImage(newBitmap, rectf); //This fuction takes very much time
catch (Exception e)
and the data I received from the sever is in JPEG form in a Memorty stream and when I make the Bitmap object from that MemoryStream its takes the maximum time
//This function takes the maximum time
newBitmap = new Bitmap((MemoryStream)receivedImage);
One thing I have noticed that If I don't assign the final bitmap to the PictureBox then these functions don't take time, however when I assign them to a PictureBox Colntrol (Mean show them to real screen).. They begin to take time.. It seems that Invalidate call is making some locks behind the scence... Is there any way to avoid these locks or whatever this delay is..???
Please help me out of it..
0 · ·