question

SindhuH-2474 avatar image
0 Votes"
SindhuH-2474 asked SindhuH-2474 answered

placing two png images side by side without cutting each other in windows form

Hello,

I am trying to place two png images on windows form with help of a picturebox.
When I place them side by side ( in which one of the png image slightly overlaps on top of the other), one of the images get cut by the other.
I have given the background color as transparent and still facing the issue.
Please help


Thanks in advance.

windows-forms
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please show your code.

0 Votes 0 ·
Castorix31 avatar image
0 Votes"
Castorix31 answered

This simple test works for me :

 Image img1 = Image.FromFile("E:\\Hulk.png");
 Image img2 = Image.FromFile("E:\\superman-flying1.png");
 int nWidth = img1.Width + img2.Width;
 int nHeight = img1.Height > img2.Height ? img1.Height : img2.Height; 
 Bitmap bmp = new Bitmap(nWidth, nHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 using (Graphics g = Graphics.FromImage(bmp))
 {
     g.DrawImage(img1, new Rectangle(new Point(), img1.Size), new Rectangle(new Point(), img1.Size), GraphicsUnit.Pixel);
     g.DrawImage(img2, new Rectangle(new Point(img1.Width, 0), img2.Size), new Rectangle(new Point(), img2.Size), GraphicsUnit.Pixel);
 }
 pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
 pictureBox1.Image = bmp;   


// 130199-2-png.jpg



2-png.jpg (54.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SindhuH-2474 avatar image
0 Votes"
SindhuH-2474 answered

Thank you for your input, but i do have to place them in a manner that they are overlapping on one another.
But when I try to do the same, the picturebox boundary cuts the another picturebox's boundary, and they don't overlap.
And I found out that that particular feature is not supported i windows form.

Thank you for the answer.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.