From 083cf9f754d3d12a3aa2671493ba0b166f3dfd47 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 18 Apr 2018 15:23:37 -0700 Subject: [PATCH] Rename GifGraphicControlExtension extension to match spec --- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 4 ++-- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 4 ++-- ...xtension.cs => GifGraphicControlExtension.cs} | 16 +++++++--------- 3 files changed, 11 insertions(+), 13 deletions(-) rename src/ImageSharp/Formats/Gif/Sections/{GifGraphicsControlExtension.cs => GifGraphicControlExtension.cs} (80%) diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 4d6f010de..1900d0df0 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// The graphics control extension. /// - private GifGraphicsControlExtension graphicsControlExtension; + private GifGraphicControlExtension graphicsControlExtension; /// /// The metadata @@ -238,7 +238,7 @@ namespace SixLabors.ImageSharp.Formats.Gif { this.stream.Read(this.buffer, 0, 6); - this.graphicsControlExtension = GifGraphicsControlExtension.Parse(this.buffer); + this.graphicsControlExtension = GifGraphicControlExtension.Parse(this.buffer); } /// diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index ecc684306..9c0ae9821 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -248,11 +248,11 @@ namespace SixLabors.ImageSharp.Formats.Gif /// The index of the color in the color palette to make transparent. private void WriteGraphicalControlExtension(ImageFrameMetaData metaData, Stream stream, int transparencyIndex) { - byte packedValue = GifGraphicsControlExtension.GetPackedValue( + byte packedValue = GifGraphicControlExtension.GetPackedValue( disposalMethod: metaData.DisposalMethod, transparencyFlag: transparencyIndex > -1); - var extension = new GifGraphicsControlExtension( + var extension = new GifGraphicControlExtension( packed: packedValue, transparencyIndex: unchecked((byte)transparencyIndex), delayTime: (ushort)metaData.FrameDelay); diff --git a/src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifGraphicControlExtension.cs similarity index 80% rename from src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs rename to src/ImageSharp/Formats/Gif/Sections/GifGraphicControlExtension.cs index a040aa900..b7b5b090c 100644 --- a/src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs +++ b/src/ImageSharp/Formats/Gif/Sections/GifGraphicControlExtension.cs @@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Formats.Gif /// processing a graphic rendering block. /// [StructLayout(LayoutKind.Sequential, Pack = 1)] - internal readonly struct GifGraphicsControlExtension : IGifExtension + internal readonly struct GifGraphicControlExtension : IGifExtension { - public GifGraphicsControlExtension( + public GifGraphicControlExtension( byte packed, ushort delayTime, byte transparencyIndex) @@ -36,9 +36,8 @@ namespace SixLabors.ImageSharp.Formats.Gif public byte Packed { get; } /// - /// Gets the delay time. - /// If not 0, this field specifies the number of hundredths (1/100) of a second to - /// wait before continuing with the processing of the Data Stream. + /// Gets the delay time in of hundredths (1/100) of a second + /// to wait before continuing with the processing of the Data Stream. /// The clock starts ticking immediately after the graphic is rendered. /// public ushort DelayTime { get; } @@ -59,7 +58,6 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// Gets a value indicating whether transparency flag is to be set. /// This indicates whether a transparency index is given in the Transparent Index field. - /// (This field is the least significant bit of the byte.) /// public bool TransparencyFlag => (this.Packed & 0x01) == 1; @@ -67,16 +65,16 @@ namespace SixLabors.ImageSharp.Formats.Gif public int WriteTo(Span buffer) { - ref GifGraphicsControlExtension dest = ref Unsafe.As(ref MemoryMarshal.GetReference(buffer)); + ref GifGraphicControlExtension dest = ref Unsafe.As(ref MemoryMarshal.GetReference(buffer)); dest = this; return 5; } - public static GifGraphicsControlExtension Parse(ReadOnlySpan buffer) + public static GifGraphicControlExtension Parse(ReadOnlySpan buffer) { - return MemoryMarshal.Cast(buffer)[0]; + return MemoryMarshal.Cast(buffer)[0]; } public static byte GetPackedValue(DisposalMethod disposalMethod, bool userInputFlag = false, bool transparencyFlag = false)