tags:

views:

84

answers:

1

I am using BufferedGraphics on Form_Paint function. Its draw my required graphic but its too much slow. Kindly give me the hints to solve this problem or any suggest me any other drawing technique for the quick response.

        BufferedGraphicsContext currentContext;
        BufferedGraphics myBuffer;
        // Gets a reference to the current BufferedGraphicsContext
        currentContext = BufferedGraphicsManager.Current;
        // Creates a BufferedGraphics instance associated with Form1, and with 
        // dimensions the same size as the drawing surface of Form1.
        myBuffer = currentContext.Allocate(this.CreateGraphics(),
          this.DisplayRectangle);
        // Draws an ellipse to the graphics buffer.

        myBuffer.Graphics.DrawImage(new Bitmap("C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures\\Pics\\Pic.jpg"), 0, 0);
        myBuffer.Graphics.DrawEllipse(Pens.Blue, 5, 90, 10, 10);
        myBuffer.Graphics.DrawRectangle(Pens.Gold, 0, 7, 500, 500);
        myBuffer.Graphics.DrawLine(Pens.Chartreuse, 0, 0, 800, 800);

        myBuffer.Render();

This is the small example of BufferedGraphics this work fine, but when the load increase it slow down.

+1  A: 

Try to use e.Graphics instead of this.CreateGraphics()

Orsol