_Original
This commit is contained in:
8
Shared/Models/Methods/IResize.cs
Normal file
8
Shared/Models/Methods/IResize.cs
Normal 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);
|
||||
|
||||
}
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user