I have a problem:
I have 3 picture boxes with 3 different images as in Image
what can i set to pictureBox3 so both images look same.....
EDITED: I want to move pictureBox3 on pictureBox2,
So there is no Option to merge them to single image
The PictureBox control is used for displaying images on the form. The Image property of the control allows you to set an image both at design time or at run time. Let's create a picture box by dragging a PictureBox control from the Toolbox and dropping it on the form.
Picture Box Vs Image Box in VBThe Image control is a lightweight control that has no device context (or hDC) or it's own. The Picturebox does have a device context and hDC and is a true "window" from the point of view of the Windows operating system (and can directly use "hWnd" parameter API calls).
Load() Displays the image specified by the ImageLocation property of the PictureBox.
The Windows Forms PictureBox control is used to display graphics in bitmap, GIF, JPEG, metafile, or icon format.
This code will do the trick:
using (Graphics g = Graphics.FromImage(pictureBox1.Image))
{
g.DrawImage(pictureBox2.Image,
(int)((pictureBox1.Image.Width - pictureBox2.Image.Width) / 2),
(int)((pictureBox1.Image.Height - pictureBox2.Image.Height) / 2));
g.Save();
pictureBox1.Refresh();
}
It will draw the image from pictureBox2 on the existing image of pictureBox1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With