GifRect.cs 1002 B

12345678910111213141516171819202122232425262728293031323334
  1. namespace PicView.Avalonia.AnimatedImage.Decoding
  2. {
  3. public readonly struct GifRect(int x, int y, int width, int height)
  4. {
  5. public int X { get; } = x;
  6. public int Y { get; } = y;
  7. public int Width { get; } = width;
  8. public int Height { get; } = height;
  9. public int TotalPixels { get; } = width * height;
  10. public static bool operator ==(GifRect a, GifRect b)
  11. {
  12. return a.X == b.X && a.Y == b.Y && a.Width == b.Width && a.Height == b.Height;
  13. }
  14. public static bool operator !=(GifRect a, GifRect b)
  15. {
  16. return !(a == b);
  17. }
  18. public override bool Equals(object? obj)
  19. {
  20. if (obj == null || GetType() != obj.GetType())
  21. return false;
  22. return this == (GifRect)obj;
  23. }
  24. public override int GetHashCode()
  25. {
  26. return X.GetHashCode() ^ Y.GetHashCode() | Width.GetHashCode() ^ Height.GetHashCode();
  27. }
  28. }
  29. }