ImageExtensions.cs - Update 'ImageLayoutInfo' and fixed issue in 'CombineImages'

This commit is contained in:
miku-666
2023-04-29 15:46:41 +02:00
parent d5a3d8fee4
commit 406dbc3ab0

View File

@@ -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);
};
}