_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

@ -0,0 +1,8 @@
namespace View_by_Distance.Shared.Models.Methods;
public interface IResize
{
(int, int, int) Get(string outputResolution, Dictionary<string, int[]> outputResolutionToResize);
}

View File

@ -30,12 +30,17 @@ public interface ILocation
static List<Models.Location> GetLocations<T>(List<MappingFromPhotoPrism> mappingFromPhotoPrismCollection, List<Models.Face> faces, List<LocationContainer<T>> containers) =>
Location.GetLocations(mappingFromPhotoPrismCollection, faces, containers);
Rectangle? TestStatic_GetNormalizedRectangle(int locationDigits, int normalizedRectangle) =>
GetNormalizedRectangle(locationDigits, normalizedRectangle);
static Rectangle? GetNormalizedRectangle(int locationDigits, int normalizedRectangle) =>
Location.GetNormalizedRectangle(locationDigits, normalizedRectangle.ToString());
Rectangle? TestStatic_GetRectangle(Rectangle checkRectangle, int locationDigits, int locationFactor, int normalizedRectangle, Models.OutputResolution outputResolution, bool useOldWay) =>
GetRectangle(checkRectangle, locationDigits, locationFactor, normalizedRectangle, outputResolution, useOldWay);
static Rectangle? GetRectangle(Rectangle checkRectangle, int locationDigits, int locationFactor, int normalizedRectangle, Models.OutputResolution outputResolution, bool useOldWay) =>
Location.GetRectangle(checkRectangle, OutputResolution.Get(outputResolution).Height, locationDigits, locationFactor, normalizedRectangle.ToString(), OutputResolution.Get(outputResolution).Width, useOldWay);
Rectangle? TestStatic_GetRectangle(int height, int locationDigits, int locationFactor, int normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width) =>
GetRectangle(height, locationDigits, locationFactor, normalizedRectangle, outputResolutionHeight, outputResolutionWidth, width);
static Rectangle? GetRectangle(int height, int locationDigits, int locationFactor, int normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width) =>
Location.GetRectangle(height, locationDigits, locationFactor, normalizedRectangle.ToString(), outputResolutionHeight, outputResolutionWidth, width);

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