日期:2014-05-17  浏览次数:21157 次

两张图片合并成一张
有身份证正反面两张图片,现在想用C# 在winform 将这张图片合并在一张图片。

------解决方案--------------------

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;
        }

------解决方案--------------------

Bitmap XXXX(Bitmap b1,Bitmap b2)
{
    Bitmap newBitmap=new Bitmap(Math.Max(b1.Width,b2.Width),b1.Height+b2.Height);