Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine two Images into one new Image

I have two JPEG files with different dimensions:

Image1 (Width1,Height1)

Image2 (Width2,Height2)

I want to create Image3 (Width3, Height3) with Image1 on the left side and Image2 on the right.

like image 388
user914313 Avatar asked Aug 26 '11 14:08

user914313


1 Answers

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);
}
like image 198
PaulB Avatar answered Sep 30 '22 16:09

PaulB