diff --git a/src/OpenCvSharp/Modules/core/Struct/Size.cs b/src/OpenCvSharp/Modules/core/Struct/Size.cs index 8aa695ba0..ca70a0d55 100644 --- a/src/OpenCvSharp/Modules/core/Struct/Size.cs +++ b/src/OpenCvSharp/Modules/core/Struct/Size.cs @@ -5,7 +5,7 @@ namespace OpenCvSharp; /// -/// +/// /// [Serializable] [StructLayout(LayoutKind.Sequential)] @@ -13,12 +13,12 @@ namespace OpenCvSharp; public struct Size : IEquatable { /// - /// + /// /// public int Width; /// - /// + /// /// public int Height; @@ -73,22 +73,32 @@ public Size(double width, double height) return !lhs.Equals(rhs); } + public static explicit operator Size(Size2d size) + { + return new(size.Width, size.Height); + } + + public static explicit operator Size(Size2f size) + { + return new(size.Width, size.Height); + } + #endregion #region Override - + /// public readonly bool Equals(Size other) { return Width == other.Width && Height == other.Height; } - + /// public override readonly bool Equals(object? obj) { return obj is Size other && Equals(other); } - + /// public override readonly int GetHashCode() { diff --git a/src/OpenCvSharp/Modules/core/Struct/Size2d.cs b/src/OpenCvSharp/Modules/core/Struct/Size2d.cs index aa6580e57..7dbd09ab7 100644 --- a/src/OpenCvSharp/Modules/core/Struct/Size2d.cs +++ b/src/OpenCvSharp/Modules/core/Struct/Size2d.cs @@ -6,19 +6,19 @@ namespace OpenCvSharp; /// -/// +/// /// [Serializable] [StructLayout(LayoutKind.Sequential)] public struct Size2d : IEquatable { /// - /// + /// /// public double Width; /// - /// + /// /// public double Height; @@ -68,22 +68,32 @@ public Size2d(double width, double height) return !lhs.Equals(rhs); } + public static implicit operator Size2d(Size size) + { + return new(size.Width, size.Height); + } + + public static implicit operator Size2d(Size2f size) + { + return new(size.Width, size.Height); + } + #endregion #region Override - + /// public readonly bool Equals(Size2d other) { return Width.Equals(other.Width) && Height.Equals(other.Height); } - + /// public override readonly bool Equals(object? obj) { return obj is Size2d other && Equals(other); } - + /// public override readonly int GetHashCode() { diff --git a/src/OpenCvSharp/Modules/core/Struct/Size2f.cs b/src/OpenCvSharp/Modules/core/Struct/Size2f.cs index caf63e798..c57105137 100644 --- a/src/OpenCvSharp/Modules/core/Struct/Size2f.cs +++ b/src/OpenCvSharp/Modules/core/Struct/Size2f.cs @@ -6,7 +6,7 @@ namespace OpenCvSharp; /// -/// +/// /// [Serializable] [StructLayout(LayoutKind.Sequential)] @@ -14,12 +14,12 @@ namespace OpenCvSharp; public struct Size2f : IEquatable { /// - /// + /// /// public float Width; /// - /// + /// /// public float Height; @@ -69,22 +69,32 @@ public Size2f(double width, double height) return !lhs.Equals(rhs); } + public static implicit operator Size2f(Size size) + { + return new(size.Width, size.Height); + } + + public static explicit operator Size2f(Size2d size) + { + return new(size.Width, size.Height); + } + #endregion #region Override - + /// public readonly bool Equals(Size2f other) { return Width.Equals(other.Width) && Height.Equals(other.Height); } - + /// public override readonly bool Equals(object? obj) { return obj is Size2f other && Equals(other); } - + /// public override readonly int GetHashCode() {