From f1c05eec693047c01db7ff0b7a79cc497a80af81 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 22 Jan 2023 12:42:44 +0100 Subject: [PATCH] Remove not used IccClut constructors --- .../Icc/Calculators/ClutCalculator.cs | 2 + .../Metadata/Profiles/ICC/Various/IccClut.cs | 83 +++---------------- 2 files changed, 13 insertions(+), 72 deletions(-) diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs index dc857bcd01..fe47328985 100644 --- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs +++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs @@ -63,6 +63,8 @@ internal class ClutCalculator : IVector4Calculator this.indexFactor = this.CalculateIndexFactor(); + // TODO: Using here a flat array instead of a jagged array to match the reference implementation. + // Maybe consider changing the clut values from jagged to a flat in IccClut to avoid this allocation. this.lutFlat = new float[this.lut.Length * 3]; int offset = 0; for (int i = 0; i < this.lut.Length; i++) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs index 26a882810e..68b9beefea 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs @@ -1,19 +1,19 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; /// -/// Color Lookup Table +/// Color Lookup Table. /// internal sealed class IccClut : IEquatable { /// /// Initializes a new instance of the class. /// - /// The CLUT values - /// The gridpoint count - /// The data type of this CLUT + /// The CLUT values. + /// The gridpoint count. + /// The data type of this CLUT. public IccClut(float[][] values, byte[] gridPointCount, IccClutDataType type) { Guard.NotNull(values, nameof(values)); @@ -28,85 +28,27 @@ internal sealed class IccClut : IEquatable } /// - /// Initializes a new instance of the class. - /// - /// The CLUT values - /// The gridpoint count - public IccClut(ushort[][] values, byte[] gridPointCount) - { - Guard.NotNull(values, nameof(values)); - Guard.NotNull(gridPointCount, nameof(gridPointCount)); - - const float Max = ushort.MaxValue; - - this.Values = new float[values.Length][]; - for (int i = 0; i < values.Length; i++) - { - this.Values[i] = new float[values[i].Length]; - for (int j = 0; j < values[i].Length; j++) - { - this.Values[i][j] = values[i][j] / Max; - } - } - - this.DataType = IccClutDataType.UInt16; - this.InputChannelCount = gridPointCount.Length; - this.OutputChannelCount = values[0].Length; - this.GridPointCount = gridPointCount; - this.CheckValues(); - } - - /// - /// Initializes a new instance of the class. - /// - /// The CLUT values - /// The gridpoint count - public IccClut(byte[][] values, byte[] gridPointCount) - { - Guard.NotNull(values, nameof(values)); - Guard.NotNull(gridPointCount, nameof(gridPointCount)); - - const float Max = byte.MaxValue; - - this.Values = new float[values.Length][]; - for (int i = 0; i < values.Length; i++) - { - this.Values[i] = new float[values[i].Length]; - for (int j = 0; j < values[i].Length; j++) - { - this.Values[i][j] = values[i][j] / Max; - } - } - - this.DataType = IccClutDataType.UInt8; - this.InputChannelCount = gridPointCount.Length; - this.OutputChannelCount = values[0].Length; - this.GridPointCount = gridPointCount; - this.CheckValues(); - } - - /// - /// Gets the values that make up this table + /// Gets the values that make up this table. /// public float[][] Values { get; } /// - /// Gets the CLUT data type (important when writing a profile) + /// Gets the CLUT data type (important when writing a profile). /// public IccClutDataType DataType { get; } /// - /// Gets the number of input channels + /// Gets the number of input channels. /// public int InputChannelCount { get; } /// - /// Gets the number of output channels + /// Gets the number of output channels. /// public int OutputChannelCount { get; } /// - /// Gets the number of grid points per input channel + /// Gets the number of grid points per input channel. /// public byte[] GridPointCount { get; } @@ -134,15 +76,12 @@ internal sealed class IccClut : IEquatable public override bool Equals(object? obj) => obj is IccClut other && this.Equals(other); /// - public override int GetHashCode() - { - return HashCode.Combine( + public override int GetHashCode() => HashCode.Combine( this.Values, this.DataType, this.InputChannelCount, this.OutputChannelCount, this.GridPointCount); - } private bool EqualsValuesArray(IccClut other) {