Skip to content

Commit 3660396

Browse files
committed
实现相等判断逻辑
1 parent 1d75d72 commit 3660396

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/MediaConverters/MediaConverters.Lib/Imaging/Effects/Colors/ColorMetadata.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using System;
2+
23
using SixLabors.ImageSharp.PixelFormats;
34

45
namespace DotNetCampus.MediaConverters.Imaging.Effects.Colors;
56

6-
public readonly struct ColorMetadata
7+
public readonly struct ColorMetadata : IEquatable<ColorMetadata>
78
{
89
public ColorMetadata(Rgba32 color)
910
{
@@ -68,4 +69,19 @@ public float GetGrayScale()
6869
var b = ARGB.B;
6970
return 0.30f * r + 0.59f * g + 0.11f * b;
7071
}
72+
73+
public bool Equals(ColorMetadata other)
74+
{
75+
return Color.Equals(other.Color);
76+
}
77+
78+
public override bool Equals(object? obj)
79+
{
80+
return obj is ColorMetadata other && Equals(other);
81+
}
82+
83+
public override int GetHashCode()
84+
{
85+
return Color.GetHashCode();
86+
}
7187
}

0 commit comments

Comments
 (0)