Browse Source

Use const color profile name

pull/2110/head
Brian Popow 4 years ago
parent
commit
35d1473d7a
  1. 9
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

9
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary> /// <summary>
/// The color profile name. /// The color profile name.
/// </summary> /// </summary>
private const string ProfileName = "ICC Profile"; private const string ColorProfileName = "ICC Profile";
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PngEncoderCore" /> class. /// Initializes a new instance of the <see cref="PngEncoderCore" /> class.
@ -718,16 +718,15 @@ namespace SixLabors.ImageSharp.Formats.Png
return; return;
} }
string profileName = "ICC Profile";
byte[] iccProfileBytes = metaData.IccProfile.ToByteArray(); byte[] iccProfileBytes = metaData.IccProfile.ToByteArray();
byte[] compressedData = this.GetZlibCompressedBytes(iccProfileBytes); byte[] compressedData = this.GetZlibCompressedBytes(iccProfileBytes);
int payloadLength = profileName.Length + compressedData.Length + 2; int payloadLength = ColorProfileName.Length + compressedData.Length + 2;
using (IMemoryOwner<byte> owner = this.memoryAllocator.Allocate<byte>(payloadLength)) using (IMemoryOwner<byte> owner = this.memoryAllocator.Allocate<byte>(payloadLength))
{ {
Span<byte> outputBytes = owner.GetSpan(); Span<byte> outputBytes = owner.GetSpan();
PngConstants.Encoding.GetBytes(profileName).CopyTo(outputBytes); PngConstants.Encoding.GetBytes(ColorProfileName).CopyTo(outputBytes);
int bytesWritten = profileName.Length; int bytesWritten = ColorProfileName.Length;
outputBytes[bytesWritten++] = 0; // Null separator. outputBytes[bytesWritten++] = 0; // Null separator.
outputBytes[bytesWritten++] = 0; // Compression. outputBytes[bytesWritten++] = 0; // Compression.
compressedData.CopyTo(outputBytes.Slice(bytesWritten)); compressedData.CopyTo(outputBytes.Slice(bytesWritten));

Loading…
Cancel
Save