Combine two Images into one new Image

后端 未结 3 1116
暗喜
暗喜 2020-11-29 07:57

I have two JPEG files with different dimensions:

Image1 (Width1,Height1)

Image2 (Width2,Height2)

I want to create Image3 (Width3, Height3) with Image

3条回答
  •  被撕碎了的回忆
    2020-11-29 08:06

    Something like this will give you a new image with the two original images side by side.

    Bitmap bitmap = new Bitmap(image1.Width + image2.Width, Math.Max(image1.Height, image2.Height));
    using (Graphics g = Graphics.FromImage(bitmap))
    {
        g.DrawImage(image1, 0, 0);
        g.DrawImage(image2, image1.Width, 0);
    }
    

提交回复
热议问题