drawing takes a few seconds?

  • Thread starter Thread starter Jeroen Ceuppens
  • Start date Start date
J

Jeroen Ceuppens

When I draw a bmp, it takes e few seconds before it shows on the screen, is
it because the onpain method is only active after x seconds? What can I
change about the code to let the bmp drawn immediatly?

CODE:
private void button1_Click(object sender, System.EventArgs e)

{

draw=true;

bmp = new Bitmap(@"\\GERONIMO\im\ImageWarpIllum.bmp");

this.Invalidate(new Rectangle(100,100,100,100));

//this.Refresh();

}

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint(e);


g=this.CreateGraphics();

if (draw)

g.DrawImage(bmp,100,100);

}
 
Have you tried using this.Update()?

Regards,
Maarten Struys, eMVP
PTS Software bv
 
Don't create Graphics in the OnPaint event. Use the one
that's passed in the event itself:


protected override void OnPaint(PaintEventArgs e)
{
if (draw)
e.Graphics.DrawImage(bmp,100,100);

base.OnPaint(e);

}
 
Back
Top