在PictureBox中組合多個圖像可以使用以下方法之一:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Image image1 = Image.FromFile("image1.jpg");
Image image2 = Image.FromFile("image2.jpg");
g.DrawImage(image1, 0, 0);
g.DrawImage(image2, 100, 100);
}
private void CombineImages()
{
Image image1 = Image.FromFile("image1.jpg");
Image image2 = Image.FromFile("image2.jpg");
Bitmap combinedImage = new Bitmap(image1.Width + image2.Width, Math.Max(image1.Height, image2.Height));
using (Graphics g = Graphics.FromImage(combinedImage))
{
g.DrawImage(image1, 0, 0);
g.DrawImage(image2, image1.Width, 0);
}
pictureBox1.Image = combinedImage;
}
這樣就可以在PictureBox中顯示多個圖像組合的效果。