From 406dbc3ab0499884d701e0ffc2865c8c95b34698 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 29 Apr 2023 15:46:41 +0200 Subject: [PATCH] ImageExtensions.cs - Update 'ImageLayoutInfo' and fixed issue in 'CombineImages' --- .../Classes/Extensions/ImageExtensions.cs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/PCK-Studio/Classes/Extensions/ImageExtensions.cs b/PCK-Studio/Classes/Extensions/ImageExtensions.cs index a41adb41..9037fa2d 100644 --- a/PCK-Studio/Classes/Extensions/ImageExtensions.cs +++ b/PCK-Studio/Classes/Extensions/ImageExtensions.cs @@ -28,9 +28,27 @@ namespace PckStudio.Extensions public ImageLayoutInfo(int width, int height, int index, ImageLayoutDirection layoutDirection) { - bool horizontal = layoutDirection == ImageLayoutDirection.Horizontal; - SectionSize = horizontal ? new Size(width, width) : new Size(height, height); - SectionPoint = horizontal ? new Point(0, index * width) : new Point(index * height, 0); + switch(layoutDirection) + { + case ImageLayoutDirection.Horizontal: + { + SectionSize = new Size(height,height); + SectionPoint = new Point(index * height, 0); + } + break; + + case ImageLayoutDirection.Vertical: + { + SectionSize = new Size(width, width); + SectionPoint = new Point(0, index * width); + } + break; + + default: + SectionSize = Size.Empty; + SectionPoint = new Point(-1, -1); + break; + } SectionArea = new Rectangle(SectionPoint, SectionSize); } } @@ -86,7 +104,7 @@ namespace PckStudio.Extensions { foreach (var (i, texture) in sources.enumerate()) { - var info = new ImageLayoutInfo(imageSize.Width, imageSize.Height, i, layoutDirection); + var info = new ImageLayoutInfo(texture.Width, texture.Height, i, layoutDirection); graphic.DrawImage(texture, info.SectionPoint); }; }