Browse Source

Rename GifGraphicControlExtension extension to match spec

pull/536/head
Jason Nelson 8 years ago
parent
commit
083cf9f754
  1. 4
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  2. 4
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  3. 16
      src/ImageSharp/Formats/Gif/Sections/GifGraphicControlExtension.cs

4
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary>
/// The graphics control extension.
/// </summary>
private GifGraphicsControlExtension graphicsControlExtension;
private GifGraphicControlExtension graphicsControlExtension;
/// <summary>
/// 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);
}
/// <summary>

4
src/ImageSharp/Formats/Gif/GifEncoderCore.cs

@ -248,11 +248,11 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <param name="transparencyIndex">The index of the color in the color palette to make transparent.</param>
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);

16
src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs → src/ImageSharp/Formats/Gif/Sections/GifGraphicControlExtension.cs

@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// processing a graphic rendering block.
/// </summary>
[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; }
/// <summary>
/// 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.
/// </summary>
public ushort DelayTime { get; }
@ -59,7 +58,6 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// <summary>
/// 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.)
/// </summary>
public bool TransparencyFlag => (this.Packed & 0x01) == 1;
@ -67,16 +65,16 @@ namespace SixLabors.ImageSharp.Formats.Gif
public int WriteTo(Span<byte> buffer)
{
ref GifGraphicsControlExtension dest = ref Unsafe.As<byte, GifGraphicsControlExtension>(ref MemoryMarshal.GetReference(buffer));
ref GifGraphicControlExtension dest = ref Unsafe.As<byte, GifGraphicControlExtension>(ref MemoryMarshal.GetReference(buffer));
dest = this;
return 5;
}
public static GifGraphicsControlExtension Parse(ReadOnlySpan<byte> buffer)
public static GifGraphicControlExtension Parse(ReadOnlySpan<byte> buffer)
{
return MemoryMarshal.Cast<byte, GifGraphicsControlExtension>(buffer)[0];
return MemoryMarshal.Cast<byte, GifGraphicControlExtension>(buffer)[0];
}
public static byte GetPackedValue(DisposalMethod disposalMethod, bool userInputFlag = false, bool transparencyFlag = false)
Loading…
Cancel
Save