Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'UVtools.Core/Enumerations.cs')
-rw-r--r--UVtools.Core/Enumerations.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/UVtools.Core/Enumerations.cs b/UVtools.Core/Enumerations.cs
index 468b389..98be0a5 100644
--- a/UVtools.Core/Enumerations.cs
+++ b/UVtools.Core/Enumerations.cs
@@ -5,7 +5,10 @@
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
+
+using System;
using System.ComponentModel;
+using Emgu.CV.CvEnum;
namespace UVtools.Core
{
@@ -24,11 +27,27 @@ namespace UVtools.Core
public enum FlipDirection : byte
{
+ None,
Horizontally,
Vertically,
Both,
}
+ public enum RotateDirection : sbyte
+ {
+ [Description("None")]
+ None = -1,
+ /// <summary>Rotate 90 degrees clockwise (0)</summary>
+ [Description("Rotate 90º CW")]
+ Rotate90Clockwise = 0,
+ /// <summary>Rotate 180 degrees clockwise (1)</summary>
+ [Description("Rotate 180º")]
+ Rotate180 = 1,
+ /// <summary>Rotate 270 degrees clockwise (2)</summary>
+ [Description("Rotate 90º CCW")]
+ Rotate90CounterClockwise = 2,
+ }
+
public enum Anchor : byte
{
TopLeft, TopCenter, TopRight,
@@ -51,5 +70,29 @@ namespace UVtools.Core
[Description("Disabled")]
NoAction
}
+
+ public static FlipType ToOpenCVFlipType(FlipDirection flip)
+ {
+ return flip switch
+ {
+ FlipDirection.None => throw new NotSupportedException($"Flip type: {flip} is not supported by OpenCV."),
+ FlipDirection.Horizontally => FlipType.Horizontal,
+ FlipDirection.Vertically => FlipType.Vertical,
+ FlipDirection.Both => FlipType.Both,
+ _ => throw new ArgumentOutOfRangeException(nameof(flip), flip, null)
+ };
+ }
+
+ public static RotateFlags ToOpenCVRotateFlags(RotateDirection rotate)
+ {
+ return rotate switch
+ {
+ RotateDirection.None => throw new NotSupportedException($"Rotate direction: {rotate} is not supported by OpenCV."),
+ RotateDirection.Rotate90Clockwise => RotateFlags.Rotate90Clockwise,
+ RotateDirection.Rotate90CounterClockwise => RotateFlags.Rotate90CounterClockwise,
+ RotateDirection.Rotate180 => RotateFlags.Rotate180,
+ _ => throw new ArgumentOutOfRangeException(nameof(rotate), rotate, null)
+ };
+ }
}
}