B
Brian Ward
I have a moving bitmap graphic, driven by a timer, on a form that has a
background image.
I want to clear the image after each movement to avoid a trail being
left behind. I can do this with a simple background colour by using
g.Clear() with the relevant colour .. but I'm not clear(sorry!) about
how to do it when there is a background image.
Some relevant code in the tick method is :
Size s1 = new Size(150,120);
Bitmap im1 = new Bitmap("myPic.gif" ,s1);
Graphics g = CreateGraphics();
g.DrawImage(im1, x,y);
g.Clear(this.BackgroundImage); // no .. not this!
g.CopyFromScreen(x,y,x,y,s1); // is this perhaps nearly right?
The last line gives a partial solution .. is this the right way?
----
Another thing I don't understand .. if I set the background image (a wmf
file) in form design mode and set the stretch mode .. the background is
fine .. but if do this at runtime when the form loads:
this.BackgroundImage = Image.FromFile("City2.wmf");
this.BackgroundImageLayout = ImageLayout.Stretch;
the image doesn't fill the screen .. while another image doesn't show at all!
If I convert them to bitmaps before loading up .. its OK .. but I don't
like not understanding why I have to do this.
TIA
===
Brian
===
background image.
I want to clear the image after each movement to avoid a trail being
left behind. I can do this with a simple background colour by using
g.Clear() with the relevant colour .. but I'm not clear(sorry!) about
how to do it when there is a background image.
Some relevant code in the tick method is :
Size s1 = new Size(150,120);
Bitmap im1 = new Bitmap("myPic.gif" ,s1);
Graphics g = CreateGraphics();
g.DrawImage(im1, x,y);
g.Clear(this.BackgroundImage); // no .. not this!
g.CopyFromScreen(x,y,x,y,s1); // is this perhaps nearly right?
The last line gives a partial solution .. is this the right way?
----
Another thing I don't understand .. if I set the background image (a wmf
file) in form design mode and set the stretch mode .. the background is
fine .. but if do this at runtime when the form loads:
this.BackgroundImage = Image.FromFile("City2.wmf");
this.BackgroundImageLayout = ImageLayout.Stretch;
the image doesn't fill the screen .. while another image doesn't show at all!
If I convert them to bitmaps before loading up .. its OK .. but I don't
like not understanding why I have to do this.
TIA
===
Brian
===