[C#]利用FlowLayoutPanel控制項合併大量圖片
namespace WindowsFormsApplication5 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK )
{
listBox1.Items.Clear();
listBox1.Items.AddRange(openFileDialog1.FileNames);
}
}
private void button2_Click(object sender, EventArgs e)
{
flowLayoutPanel1.Controls.Clear();
foreach(string file in listBox1.Items){
flowLayoutPanel1.Controls.Add(new PictureBox() { Image = new Bitmap(file), SizeMode = PictureBoxSizeMode.AutoSize, Margin=new Padding(0)});
}
}
private void button3_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
Bitmap b = new Bitmap(flowLayoutPanel1.Width, flowLayoutPanel1.Height);
flowLayoutPanel1.DrawToBitmap(b, flowLayoutPanel1.ClientRectangle);
b.Save(saveFileDialog1.FileName );
}
}
}
} 操作步驟與執行結果Step1.開啟程式,並按下[Load Photo]按鈕 Step2.選取圖片後按下[開啟] 程式會顯示所選取的所有圖片路徑 Step3.按下[合併]按鈕 合併完後會圖片會顯示在下方的FlowLayoutPanel區域 Step5.按下[Save]按鈕,在彈出的視窗選取存檔位置並按下儲存即可 儲存的檔案會像下面這樣合併完成 Download MergePhoto.zip Link.NET菜鳥自救會-[C#]大量圖片合併程式