Browse Source

Refactored byte[] array in PngConstants type

pull/1133/head
Sergio Pedri 6 years ago
parent
commit
aa6552632c
  1. 1
      src/ImageSharp/Common/Extensions/StreamExtensions.cs
  2. 5
      src/ImageSharp/Formats/Png/PngConstants.cs
  3. 2
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

1
src/ImageSharp/Common/Extensions/StreamExtensions.cs

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0.
using System;
using System.Buffers;
using System.IO;
using SixLabors.ImageSharp.Memory;

5
src/ImageSharp/Formats/Png/PngConstants.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.Text;
@ -37,9 +38,9 @@ namespace SixLabors.ImageSharp.Formats.Png
public static readonly IEnumerable<string> FileExtensions = new[] { "png" };
/// <summary>
/// The header bytes identifying a Png.
/// Gets the header bytes identifying a Png.
/// </summary>
public static readonly byte[] HeaderBytes =
public static ReadOnlySpan<byte> HeaderBytes => new byte[]
{
0x89, // Set the high bit.
0x50, // P

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

@ -149,7 +149,7 @@ namespace SixLabors.ImageSharp.Formats.Png
QuantizedFrame<TPixel> quantized = PngEncoderOptionsHelpers.CreateQuantizedFrame(this.options, image);
this.bitDepth = PngEncoderOptionsHelpers.CalculateBitDepth(this.options, image, quantized);
stream.Write(PngConstants.HeaderBytes, 0, PngConstants.HeaderBytes.Length);
stream.Write(PngConstants.HeaderBytes);
this.WriteHeaderChunk(stream);
this.WritePaletteChunk(stream, quantized);

Loading…
Cancel
Save