Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A PictureBox Problem

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.....

alt text

EDITED: I want to move pictureBox3 on pictureBox2,

So there is no Option to merge them to single image

like image 926
Javed Akram Avatar asked Nov 10 '10 12:11

Javed Akram


People also ask

What is a PictureBox control used for?

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.

What is image box and box?

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).

Which method is used to load image in a PictureBox?

Load() Displays the image specified by the ImageLocation property of the PictureBox.

What are the different image formats that a PictureBox control can display?

The Windows Forms PictureBox control is used to display graphics in bitmap, GIF, JPEG, metafile, or icon format.


1 Answers

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.

like image 199
Shadow Wizard Hates Omicron Avatar answered Oct 12 '22 07:10

Shadow Wizard Hates Omicron