将多个图片框合并为一个并保持其位置

Combine multiple picturebox into one retaining its position

我有3个pictureBox,绿色是1个,两张图片在两个不同的pictureBox中。我想将所有图片框拼接成一个 .jpg 图像,保留所有图像的位置。任何人都可以帮我解决代码问题。挠我头 4 天了:(

提前致谢

        Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);

        pictureBox1.DrawToBitmap(bmp, new Rectangle(0,0,pictureBox1.Width, pictureBox1.Height));
        pictureBox2.DrawToBitmap(bmp, new Rectangle(pictureBox2.Location.X - pictureBox1.Location.X, pictureBox2.Location.Y - pictureBox1.Location.Y, pictureBox2.Width, pictureBox2.Height));
        pictureBox3.DrawToBitmap(bmp, new Rectangle(pictureBox3.Location.X - pictureBox1.Location.X, pictureBox3.Location.Y - pictureBox1.Location.Y, pictureBox3.Width, pictureBox3.Height));

        bmp.Save(@"C:\Temp\output.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);