B
BobBlack
Guest
Drawing on a PictureBox with incremental width
Hello, everyone. I'd like to ask a question about the PictureBox drawing of C#.
The following is what I want to achieve. I use Graphics objects to draw pictures on PictureBox (more precisely pictures). Pictures can be displayed, but if the form is covered, they will disappear immediately. So I set pictures to pictures with code like picturebox. image = bitmap xxxxxx, and PictureBox will not disappear.
The implementation code is as follows:
Bitmap bmp = null;
if (pictureBox1.Image != null)
{
bmp = new Bitmap( pictureBox1.Image);
}
else {
bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
}
Graphics g = Graphics.FromImage(bmp);
Point pt = new Point() {X=10 + x_a,Y=10 };
g.DrawImage(pictureBox2.Image, pt);
x_a += 20;
pictureBox1.Image = bmp;
But the problem is, after I change the size of the picturebox, I want to add some images to the back of the picture dynamically. But I found that if I exceeded the size of the original picturebox, the image would not change again.
What can be done?
Continue reading...
Hello, everyone. I'd like to ask a question about the PictureBox drawing of C#.
The following is what I want to achieve. I use Graphics objects to draw pictures on PictureBox (more precisely pictures). Pictures can be displayed, but if the form is covered, they will disappear immediately. So I set pictures to pictures with code like picturebox. image = bitmap xxxxxx, and PictureBox will not disappear.
The implementation code is as follows:
Bitmap bmp = null;
if (pictureBox1.Image != null)
{
bmp = new Bitmap( pictureBox1.Image);
}
else {
bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
}
Graphics g = Graphics.FromImage(bmp);
Point pt = new Point() {X=10 + x_a,Y=10 };
g.DrawImage(pictureBox2.Image, pt);
x_a += 20;
pictureBox1.Image = bmp;
But the problem is, after I change the size of the picturebox, I want to add some images to the back of the picture dynamically. But I found that if I exceeded the size of the original picturebox, the image would not change again.
What can be done?
Continue reading...