public void MergeImages(List<Image> imageList) { string jpg3 = "Save path"; int heights = 0; int nIndex = 0; List<int> widths = new List<int>(); foreach (Image image in imageList) { widths.Add(image.Width); heights += image.Height; } widths.Sort(); int width = widths[widths.Count - 1]; Bitmap img3 = new Bitmap(width, heights); Graphics g = Graphics.FromImage(img3); g.Clear(Color.White); foreach (Image image in imageList) { Image img = image; if (nIndex == 0) { g.DrawImage(img, new Point(0, 0)); nIndex++; width = img.Height; } else { g.DrawImage(img, new Point(0, width)); width += img.Height; } img3.Save(jpg3, System.Drawing.Imaging.ImageFormat.Jpeg); img.Dispose(); } g.Dispose(); try { img3.Save(jpg3, System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception ex) { } img3.Dispose(); }
using
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)