diff --git a/ShareX.HelpersLib/Helpers/ImageHelpers.cs b/ShareX.HelpersLib/Helpers/ImageHelpers.cs index 0b6bd4358..6acfc364b 100644 --- a/ShareX.HelpersLib/Helpers/ImageHelpers.cs +++ b/ShareX.HelpersLib/Helpers/ImageHelpers.cs @@ -2099,30 +2099,31 @@ public static Bitmap LoadImageWithFileDialog(Form form = null) return null; } - public static Bitmap CombineImages(List images, Orientation orientation = Orientation.Vertical, - ImageCombinerAlignment alignment = ImageCombinerAlignment.LeftOrTop, int space = 0, bool autoFillBackground = false) + public static Bitmap CombineImages(List images, Orientation orientation, ImageCombinerAlignment alignment = ImageCombinerAlignment.LeftOrTop, + int space = 0, bool autoFillBackground = false) { int width, height; int imageCount = images.Count; int spaceSize = space * (imageCount - 1); - if (orientation == Orientation.Vertical) - { - width = images.Max(x => x.Width); - height = images.Sum(x => x.Height) + spaceSize; - } - else + if (orientation == Orientation.Horizontal) { width = images.Sum(x => x.Width) + spaceSize; height = images.Max(x => x.Height); } + else + { + width = images.Max(x => x.Width); + height = images.Sum(x => x.Height) + spaceSize; + } Bitmap bmp = new Bitmap(width, height); using (Graphics g = Graphics.FromImage(bmp)) { g.SetHighQuality(); - int position = 0; + + Point position = new Point(0, 0); for (int i = 0; i < imageCount; i++) { @@ -2135,44 +2136,45 @@ public static Bitmap CombineImages(List images, Orientation orientation } Rectangle rect; + Point offset = new Point(0, 0); - if (orientation == Orientation.Vertical) + if (orientation == Orientation.Horizontal) { - int x; switch (alignment) { default: case ImageCombinerAlignment.LeftOrTop: - x = 0; + offset.Y = 0; break; case ImageCombinerAlignment.Center: - x = (width / 2) - (image.Width / 2); + offset.Y = (height / 2) - (image.Height / 2); break; case ImageCombinerAlignment.RightOrBottom: - x = width - image.Width; + offset.Y = height - image.Height; break; } - rect = new Rectangle(x, position, image.Width, image.Height); - position += image.Height + space; + + rect = new Rectangle(position.X + offset.X, position.Y + offset.Y, image.Width, image.Height); + position.X += image.Width + space; } else { - int y; switch (alignment) { default: case ImageCombinerAlignment.LeftOrTop: - y = 0; + offset.X = 0; break; case ImageCombinerAlignment.Center: - y = (height / 2) - (image.Height / 2); + offset.X = (width / 2) - (image.Width / 2); break; case ImageCombinerAlignment.RightOrBottom: - y = height - image.Height; + offset.X = width - image.Width; break; } - rect = new Rectangle(position, y, image.Width, image.Height); - position += image.Width + space; + + rect = new Rectangle(position.X + offset.X, position.Y + offset.Y, image.Width, image.Height); + position.Y += image.Height + space; } g.DrawImage(image, rect); @@ -2182,8 +2184,8 @@ public static Bitmap CombineImages(List images, Orientation orientation return bmp; } - public static Bitmap CombineImages(IEnumerable imageFiles, Orientation orientation = Orientation.Vertical, - ImageCombinerAlignment alignment = ImageCombinerAlignment.LeftOrTop, int space = 0, bool autoFillBackground = false) + public static Bitmap CombineImages(IEnumerable imageFiles, Orientation orientation, ImageCombinerAlignment alignment = ImageCombinerAlignment.LeftOrTop, + int space = 0, bool autoFillBackground = false) { List images = new List(); diff --git a/ShareX.MediaLib/ImageCombinerOptions.cs b/ShareX.MediaLib/ImageCombinerOptions.cs index a0f2827c8..8d77a8eb5 100644 --- a/ShareX.MediaLib/ImageCombinerOptions.cs +++ b/ShareX.MediaLib/ImageCombinerOptions.cs @@ -33,6 +33,6 @@ public class ImageCombinerOptions public Orientation Orientation { get; set; } = Orientation.Vertical; public ImageCombinerAlignment Alignment { get; set; } = ImageCombinerAlignment.LeftOrTop; public int Space { get; set; } = 0; - public bool AutoFillBackground { get; set; } = false; + public bool AutoFillBackground { get; set; } = true; } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs b/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs index fa30e01bb..9ae775dd7 100644 --- a/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/ScrollingCaptureForm.cs @@ -608,7 +608,7 @@ private Bitmap CombineImages() output.Add(newImage); } - Bitmap bmpResult = ImageHelpers.CombineImages(output); + Bitmap bmpResult = ImageHelpers.CombineImages(output, Orientation.Vertical); foreach (Bitmap image in output) {