/// <summary> /// Compares two color infos. /// </summary> /// <param name="other">Other color info.</param> /// <param name="cParts">Indicates what to compare. Default is: ComparableParts.Default. </param> /// <returns></returns> public bool Equals(ColorInfo other, ComparableParts cParts) { if (cParts == ComparableParts.Default) { return(this.ColorType == other.ColorType && this.ChannelType == other.ChannelType); } if (cParts == ComparableParts.BinaryCompatible) { var castable = (this.ChannelCount == other.ChannelCount) && (this.ChannelType == other.ChannelType); return(castable); } if (cParts == ComparableParts.Depth) { var depth = this.ChannelType == other.ChannelType; return(depth); } throw new Exception("Unknown comparison!"); }
/// <summary> /// Compares two color infos. /// </summary> /// <param name="other">Other color info.</param> /// <param name="cParts">Indicates what to compare. Default is: ComparableParts.Default. </param> /// <returns></returns> public bool Equals(ColorInfo other, ComparableParts cParts) { if (cParts == ComparableParts.Default) { return(this.ColorType == other.ColorType && this.ChannelType == other.ChannelType); } if (cParts == ComparableParts.Castable) { bool sameChannels = (this.NumberOfChannels == other.NumberOfChannels) && (this.ChannelType == other.ChannelType); bool colorsAreCastable = this.IsGenericColorSpace || other.IsGenericColorSpace || this.ColorType == other.ColorType; var castable = sameChannels && colorsAreCastable; return(castable); } if (cParts == ComparableParts.Depth) { var depth = this.ChannelType == other.ChannelType; return(depth); } throw new Exception("Unknown comparison!"); }