Browse Source

Change IccProfileSequenceIdentifier to a struct

af/merge-core
Jason Nelson 8 years ago
parent
commit
bf24dcc779
  1. 8
      src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
  2. 5
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
  3. 37
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs

8
src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs

@ -709,13 +709,15 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
// Jump over position table
long tablePosition = this.dataStream.Position;
this.dataStream.Position += length * 8;
IccPositionNumber[] table = new IccPositionNumber[length];
var table = new IccPositionNumber[length];
for (int i = 0; i < length; i++)
{
ref IccProfileSequenceIdentifier sequenceIdentifier = ref value.Data[i];
uint offset = (uint)(this.dataStream.Position - start);
int size = this.WriteProfileId(value.Data[i].Id);
size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.Data[i].Description));
int size = this.WriteProfileId(sequenceIdentifier.Id);
size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(sequenceIdentifier.Description));
size += this.WritePadding();
table[i] = new IccPositionNumber(offset, (uint)size);
count += size;

5
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs

@ -41,8 +41,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override bool Equals(IccTagDataEntry other)
{
var entry = other as IccProfileSequenceIdentifierTagDataEntry;
return entry != null && this.Equals(entry);
return other is IccProfileSequenceIdentifierTagDataEntry entry && this.Equals(entry);
}
/// <inheritdoc />
@ -74,7 +73,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
return obj is IccProfileSequenceIdentifierTagDataEntry && this.Equals((IccProfileSequenceIdentifierTagDataEntry)obj);
return obj is IccProfileSequenceIdentifierTagDataEntry other && this.Equals(other);
}
/// <inheritdoc />

37
src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs

@ -7,12 +7,12 @@ using System.Linq;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
/// <summary>
/// Description of a profile within a sequence
/// Description of a profile within a sequence.
/// </summary>
internal sealed class IccProfileSequenceIdentifier : IEquatable<IccProfileSequenceIdentifier>
internal readonly struct IccProfileSequenceIdentifier : IEquatable<IccProfileSequenceIdentifier>
{
/// <summary>
/// Initializes a new instance of the <see cref="IccProfileSequenceIdentifier"/> class.
/// Initializes a new instance of the <see cref="IccProfileSequenceIdentifier"/> struct.
/// </summary>
/// <param name="id">ID of the profile</param>
/// <param name="description">Description of the profile</param>
@ -25,44 +25,23 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
/// <summary>
/// Gets the ID of the profile
/// Gets the ID of the profile.
/// </summary>
public IccProfileId Id { get; }
/// <summary>
/// Gets the description of the profile
/// Gets the description of the profile.
/// </summary>
public IccLocalizedString[] Description { get; }
/// <inheritdoc />
public bool Equals(IccProfileSequenceIdentifier other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return this.Id.Equals(other.Id) && this.Description.SequenceEqual(other.Description);
}
public bool Equals(IccProfileSequenceIdentifier other) =>
this.Id.Equals(other.Id) &&
this.Description.SequenceEqual(other.Description);
/// <inheritdoc />
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccProfileSequenceIdentifier other && this.Equals(other);
}

Loading…
Cancel
Save