/// <inheritdoc /> public override bool Equals(IccCurveSegment other) { if (base.Equals(other) && other is IccSampledCurveElement segment) { return(this.CurveEntries.AsSpan().SequenceEqual(segment.CurveEntries)); } return(false); }
/// <inheritdoc /> public override bool Equals(IccCurveSegment other) { if (base.Equals(other) && other is IccFormulaCurveElement segment) { return(this.Type == segment.Type && this.Gamma == segment.Gamma && this.A == segment.A && this.B == segment.B && this.C == segment.C && this.D == segment.D && this.E == segment.E); } return(false); }
/// <summary> /// Writes a <see cref="IccCurveSegment"/> /// </summary> /// <param name="value">The curve to write</param> /// <returns>The number of bytes written</returns> public int WriteCurveSegment(IccCurveSegment value) { int count = this.WriteUInt32((uint)value.Signature); count += this.WriteEmpty(4); switch (value.Signature) { case IccCurveSegmentSignature.FormulaCurve: return(count + this.WriteFormulaCurveElement((IccFormulaCurveElement)value)); case IccCurveSegmentSignature.SampledCurve: return(count + this.WriteSampledCurveElement((IccSampledCurveElement)value)); default: throw new InvalidIccProfileException($"Invalid CurveSegment type of {value.Signature}"); } }
/// <summary> /// Reads a <see cref="IccOneDimensionalCurve"/> /// </summary> /// <returns>The read curve</returns> public IccOneDimensionalCurve ReadOneDimensionalCurve() { ushort segmentCount = this.ReadUInt16(); this.AddIndex(2); // 2 bytes reserved var breakPoints = new float[segmentCount - 1]; for (int i = 0; i < breakPoints.Length; i++) { breakPoints[i] = this.ReadSingle(); } var segments = new IccCurveSegment[segmentCount]; for (int i = 0; i < segmentCount; i++) { segments[i] = this.ReadCurveSegment(); } return(new IccOneDimensionalCurve(breakPoints, segments)); }