Fixed aspect ratio of images

This commit is contained in:
Jaex 2019-12-17 21:19:44 +03:00
parent 6a61d945a1
commit 196a45ff37

View file

@ -138,7 +138,18 @@ private void DrawImage(Image img, Image img2, Graphics g)
if (RandomSize)
{
width = height = MathHelpers.Random(Math.Min(RandomSizeMin, RandomSizeMax), Math.Max(RandomSizeMin, RandomSizeMax));
int size = MathHelpers.Random(Math.Min(RandomSizeMin, RandomSizeMax), Math.Max(RandomSizeMin, RandomSizeMax));
width = size;
height = size;
if (img2.Width > img2.Height)
{
height = (int)(size * ((float)img2.Height / img2.Width));
}
else if (img2.Width < img2.Height)
{
width = (int)(size * ((float)img2.Width / img2.Height));
}
}
else
{