-1

I'm a c# beginner and I'm wondering if there is a way that I could draw 2 images from 2 different pictureboxes and save it as a one image using the method DrawToBitmap.

I can preview everything nice in the program itself (it looks good), but the main problem is when I save the picture, It's just showing the picturebox1 with a blank-alike icon of the picturebox2 in the middle :/

Here's the part of my code and it's not working as it should

pictureBox2.ImageLocation = potDoSlike;
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.DrawToBitmap(bmp, pictureBox1.Bounds);
pictureBox2.DrawToBitmap(bmp, pictureBox2.Bounds);
bmp.Save(@"D:\asd.jpg");
The Dude
  • 55
  • 1
  • 11
  • How do you want to *join* the images? Overlay (on top of each other) maybe with a transparency key? Or side by side? – MrPaulch Apr 01 '15 at 16:28
  • Maybe this could help? http://stackoverflow.com/questions/465172/merging-two-images-in-c-net – Hozikimaru Apr 01 '15 at 16:29
  • Side by side, the thing is that one picturebox overlays another, but transparency is not important. In picturebox2.i'm displaying jpg pictures. Imagine it as a reciept with a picture at the bottom. – The Dude Apr 01 '15 at 16:31

1 Answers1

0

I figured it out! The problem was that I didn't save anything to the pictureBox.Image and it couldn't draw nothing out... well here's the code!

pictureBox2.Parent = pictureBox1;
pictureBox2.ImageLocation = potDoSlike;
pictureBox2.Image = Image.FromFile(potDoSlike);
Bitmap bmp = new Bitmap(pictureBox1.Image);
pictureBox1.DrawToBitmap(bmp, pictureBox1.Bounds);
pictureBox2.DrawToBitmap(bmp, pictureBox2.Bounds);
bmp.Save(@"D:\asd.jpg");
The Dude
  • 55
  • 1
  • 11