_Original

This commit is contained in:
2022-12-31 13:10:03 -07:00
parent 4b6811644c
commit 45f4401fa4
13 changed files with 197 additions and 141 deletions

View File

@ -140,7 +140,7 @@ internal abstract class Location
return result;
}
private static Rectangle? GetRectangle(int locationDigits, int height, string normalizedRectangle, int width)
internal static Rectangle? GetNormalizedRectangle(int locationDigits, string normalizedRectangle)
{
Rectangle? result;
int length = (locationDigits - 1) / 4;
@ -159,10 +159,21 @@ internal abstract class Location
if (!int.TryParse(segments[1], out int xNormalized) || !int.TryParse(segments[2], out int yNormalized) || !int.TryParse(segments[3], out int wNormalized) || !int.TryParse(segments[4], out int hNormalized))
result = null;
else
{
decimal factor = 100;
result = new((int)(xNormalized / factor * width), (int)(yNormalized / factor * height), (int)(wNormalized / factor * width), (int)(hNormalized / factor * height));
}
result = new(xNormalized, yNormalized, wNormalized, hNormalized);
}
return result;
}
private static Rectangle? GetRectangle(int locationDigits, int height, string normalizedRectangle, int width)
{
Rectangle? result;
Rectangle? rectangle = GetNormalizedRectangle(locationDigits, normalizedRectangle);
if (rectangle is null)
result = null;
else
{
decimal factor = 100;
result = new((int)(rectangle.Value.X / factor * width), (int)(rectangle.Value.Y / factor * height), (int)(rectangle.Value.Width / factor * width), (int)(rectangle.Value.Height / factor * height));
}
return result;
}