Browse Source

Remove not used IccClut constructors

pull/1567/head
Brian Popow 3 years ago
parent
commit
f1c05eec69
  1. 2
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Icc/Calculators/ClutCalculator.cs
  2. 83
      src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs

2
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++)

83
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;
/// <summary>
/// Color Lookup Table
/// Color Lookup Table.
/// </summary>
internal sealed class IccClut : IEquatable<IccClut>
{
/// <summary>
/// Initializes a new instance of the <see cref="IccClut"/> class.
/// </summary>
/// <param name="values">The CLUT values</param>
/// <param name="gridPointCount">The gridpoint count</param>
/// <param name="type">The data type of this CLUT</param>
/// <param name="values">The CLUT values.</param>
/// <param name="gridPointCount">The gridpoint count.</param>
/// <param name="type">The data type of this CLUT.</param>
public IccClut(float[][] values, byte[] gridPointCount, IccClutDataType type)
{
Guard.NotNull(values, nameof(values));
@ -28,85 +28,27 @@ internal sealed class IccClut : IEquatable<IccClut>
}
/// <summary>
/// Initializes a new instance of the <see cref="IccClut"/> class.
/// </summary>
/// <param name="values">The CLUT values</param>
/// <param name="gridPointCount">The gridpoint count</param>
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();
}
/// <summary>
/// Initializes a new instance of the <see cref="IccClut"/> class.
/// </summary>
/// <param name="values">The CLUT values</param>
/// <param name="gridPointCount">The gridpoint count</param>
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();
}
/// <summary>
/// Gets the values that make up this table
/// Gets the values that make up this table.
/// </summary>
public float[][] Values { get; }
/// <summary>
/// Gets the CLUT data type (important when writing a profile)
/// Gets the CLUT data type (important when writing a profile).
/// </summary>
public IccClutDataType DataType { get; }
/// <summary>
/// Gets the number of input channels
/// Gets the number of input channels.
/// </summary>
public int InputChannelCount { get; }
/// <summary>
/// Gets the number of output channels
/// Gets the number of output channels.
/// </summary>
public int OutputChannelCount { get; }
/// <summary>
/// Gets the number of grid points per input channel
/// Gets the number of grid points per input channel.
/// </summary>
public byte[] GridPointCount { get; }
@ -134,15 +76,12 @@ internal sealed class IccClut : IEquatable<IccClut>
public override bool Equals(object? obj) => obj is IccClut other && this.Equals(other);
/// <inheritdoc/>
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)
{

Loading…
Cancel
Save