public Bitmap Join(params Bitmap[] bmp)
{
int width = bmp.OrderBy(d => d.Width).Last().Width;
int height = 0;
foreach (var item in bmp)
{
height += item.Height;
}
Bitmap res = new Bitmap(width, height);
int now = 0;
foreach (var item in bmp)
{
for (int i = 0; i < item.Width; i++)
{
for (int k = 0; k < item.Height; k++)
{
res.SetPixel(i, k + now, item.GetPixel(i, k));
}
}
now += item.Height;
}
return res;
}
Join(new Bitmap("f://20130711153357.jpg"), new Bitmap("f://20130711153357.jpg")).Save("f://1.jpg", ImageFormat.Jpeg);结果
Bitmap XXXX(Bitmap b1,Bitmap b2)
{
Bitmap newBitmap=new Bitmap(Math.Max(b1.Width,b2.Width),b1.Height+b2.Height);
Graphics g=Graphics.FromImage(newBitmap);
g.DrawImage(b1,0,0);
g.DrawImage(b2,0,b1.Height);
g.Dispose();
return newBitmap;
}