internal new static async Task <GifExtension> ReadAsync(Stream stream, IEnumerable <GifExtension> controlExtensions) { // Note: at this point, the Extension Introducer (0x21) has already been read int label = stream.ReadByte(); if (label < 0) { throw new EndOfStreamException(); } switch (label) { case GifGraphicControlExtension.ExtensionLabel: return(await GifGraphicControlExtension.ReadAsync(stream).ConfigureAwait(false)); case GifCommentExtension.ExtensionLabel: return(await GifCommentExtension.ReadAsync(stream).ConfigureAwait(false)); case GifPlainTextExtension.ExtensionLabel: return(await GifPlainTextExtension.ReadAsync(stream, controlExtensions).ConfigureAwait(false)); case GifApplicationExtension.ExtensionLabel: return(await GifApplicationExtension.ReadAsync(stream).ConfigureAwait(false)); default: throw GifHelpers.UnknownExtensionTypeException(label); } }
internal static async Task <GifApplicationExtension> ReadAsync(Stream stream) { var ext = new GifApplicationExtension(); await ext.ReadInternalAsync(stream).ConfigureAwait(false); return(ext); }
internal static async Task <GifExtension> ReadAsync(Stream stream, IEnumerable <GifExtension> controlExtensions) { int label = stream.ReadByte(); if (label < 0) { throw GifHelpers.UnexpectedEndOfStreamException(); } switch (label) { case 254: return((GifExtension)await GifCommentExtension.ReadAsync(stream).ConfigureAwait(false)); case (int)byte.MaxValue: return((GifExtension)await GifApplicationExtension.ReadAsync(stream).ConfigureAwait(false)); case 1: return((GifExtension)await GifPlainTextExtension.ReadAsync(stream, controlExtensions).ConfigureAwait(false)); case 249: return((GifExtension)await GifGraphicControlExtension.ReadAsync(stream).ConfigureAwait(false)); default: throw GifHelpers.UnknownExtensionTypeException(label); } }
public static ushort GetRepeatCount(GifApplicationExtension ext) { if (ext.Data.Length >= 3) { return BitConverter.ToUInt16(ext.Data, 1); } return 1; }
public static ushort GetRepeatCount(GifApplicationExtension ext) { if (ext.Data.Length >= 3) { return(BitConverter.ToUInt16(ext.Data, 1)); } return(1); }
public static bool IsNetscapeExtension(GifApplicationExtension ext) { if (ext.ApplicationIdentifier == "NETSCAPE") { return(GifHelpers.GetString(ext.AuthenticationCode) == "2.0"); } return(false); }
private async Task ReadInternalAsync(Stream stream) { this.Header = await GifHeader.ReadAsync(stream).ConfigureAwait(false); if (this.Header.LogicalScreenDescriptor.HasGlobalColorTable) { this.GlobalColorTable = await GifHelpers.ReadColorTableAsync(stream, this.Header.LogicalScreenDescriptor.GlobalColorTableSize).ConfigureAwait(false); } await this.ReadFramesAsync(stream).ConfigureAwait(false); GifApplicationExtension ext = this.Extensions.OfType <GifApplicationExtension>().FirstOrDefault <GifApplicationExtension>(new Func <GifApplicationExtension, bool>(GifHelpers.IsNetscapeExtension)); this.RepeatCount = ext != null?GifHelpers.GetRepeatCount(ext) : (ushort)1; }
public static bool IsNetscapeExtension(GifApplicationExtension ext) { return ext.ApplicationIdentifier == "NETSCAPE" && GetString(ext.AuthenticationCode) == "2.0"; }
public static bool IsNetscapeExtension(GifApplicationExtension ext) { return(ext.ApplicationIdentifier == "NETSCAPE" && GetString(ext.AuthenticationCode) == "2.0"); }
internal static async Task<GifApplicationExtension> ReadAsync(Stream stream) { var ext = new GifApplicationExtension(); await ext.ReadInternalAsync(stream).ConfigureAwait(false); return ext; }