I am trying to draw two images side by side using the C # Drawing namespace. Here is a very simple example, assuming two images of the same height:
Image[] oldImages = GetOldImages();
var newImage = new Bitmap(oldImages[0].Width + oldImages[1].Width, 800);
using (var newImageGraphics = Graphics.FromImage(newImage))
{
newImageGraphics.DrawImage(oldImages[0], 0, 0);
newImageGraphics.DrawImage(oldImages[1], oldImage[0].Width, 0);
newImageGraphics.Save();
}
This works fine if the resolution of the two old images is the same.
However, if the resolutions are different from each other, the image changes, which causes problems. For example, if the first image has a different resolution, then the second image will not be set correctly.
Does anyone know how I can solve this problem easily? Ideally, I want the original height and width of the image to remain unchanged when they are drawn on a new image.