private async Task ReadInternalAsync(Stream stream, IEnumerable <GifExtension> controlExtensions) { // Note: at this point, the label (0x01) has already been read byte[] bytes = new byte[13]; await stream.ReadAllAsync(bytes, 0, bytes.Length).ConfigureAwait(false); BlockSize = bytes[0]; if (BlockSize != 12) { throw GifHelpers.InvalidBlockSizeException("Plain Text Extension", 12, BlockSize); } Left = BitConverter.ToUInt16(bytes, 1); Top = BitConverter.ToUInt16(bytes, 3); Width = BitConverter.ToUInt16(bytes, 5); Height = BitConverter.ToUInt16(bytes, 7); CellWidth = bytes[9]; CellHeight = bytes[10]; ForegroundColorIndex = bytes[11]; BackgroundColorIndex = bytes[12]; var dataBytes = await GifHelpers.ReadDataBlocksAsync(stream).ConfigureAwait(false); Text = GifHelpers.GetString(dataBytes); Extensions = controlExtensions.ToList().AsReadOnly(); }
private async Task ReadInternalAsync(Stream stream) { byte[] bytes = new byte[12]; await stream.ReadAllAsync(bytes, 0, bytes.Length).ConfigureAwait(false); this.BlockSize = (int)bytes[0]; if (this.BlockSize != 11) { throw GifHelpers.InvalidBlockSizeException("Application Extension", 11, this.BlockSize); } this.ApplicationIdentifier = GifHelpers.GetString(bytes, 1, 8); byte[] numArray = new byte[3]; Array.Copy((Array)bytes, 9, (Array)numArray, 0, 3); this.AuthenticationCode = numArray; this.Data = await GifHelpers.ReadDataBlocksAsync(stream, false).ConfigureAwait(false); }
private async Task ReadInternalAsync(Stream stream) { byte[] bytes = new byte[6]; await stream.ReadAllAsync(bytes, 0, bytes.Length).ConfigureAwait(false); this.BlockSize = (int)bytes[0]; if (this.BlockSize != 4) { throw GifHelpers.InvalidBlockSizeException("Graphic Control Extension", 4, this.BlockSize); } byte num = bytes[1]; this.DisposalMethod = (GifFrameDisposalMethod)(((int)num & 28) >> 2); this.UserInput = ((uint)num & 2U) > 0U; this.HasTransparency = ((uint)num & 1U) > 0U; this.Delay = (int)BitConverter.ToUInt16(bytes, 2) * 10; this.TransparencyIndex = (int)bytes[4]; }
private async Task ReadInternalAsync(Stream stream) { // Note: at this point, the label (0xFF) has already been read byte[] bytes = new byte[12]; await stream.ReadAllAsync(bytes, 0, bytes.Length).ConfigureAwait(false); BlockSize = bytes[0]; // should always be 11 if (BlockSize != 11) { throw GifHelpers.InvalidBlockSizeException("Application Extension", 11, BlockSize); } ApplicationIdentifier = GifHelpers.GetString(bytes, 1, 8); byte[] authCode = new byte[3]; Array.Copy(bytes, 9, authCode, 0, 3); AuthenticationCode = authCode; Data = await GifHelpers.ReadDataBlocksAsync(stream).ConfigureAwait(false); }
private async Task ReadInternalAsync(Stream stream) { // Note: at this point, the label (0xF9) has already been read byte[] bytes = new byte[6]; await stream.ReadAllAsync(bytes, 0, bytes.Length).ConfigureAwait(false); BlockSize = bytes[0]; // should always be 4 if (BlockSize != 4) { throw GifHelpers.InvalidBlockSizeException("Graphic Control Extension", 4, BlockSize); } byte packedFields = bytes[1]; DisposalMethod = (GifFrameDisposalMethod)((packedFields & 0x1C) >> 2); UserInput = (packedFields & 0x02) != 0; HasTransparency = (packedFields & 0x01) != 0; Delay = BitConverter.ToUInt16(bytes, 2) * 10; // milliseconds TransparencyIndex = bytes[4]; }
private async Task ReadInternalAsync(Stream stream, IEnumerable <GifExtension> controlExtensions) { byte[] bytes = new byte[13]; await stream.ReadAllAsync(bytes, 0, bytes.Length).ConfigureAwait(false); this.BlockSize = (int)bytes[0]; if (this.BlockSize != 12) { throw GifHelpers.InvalidBlockSizeException("Plain Text Extension", 12, this.BlockSize); } this.Left = (int)BitConverter.ToUInt16(bytes, 1); this.Top = (int)BitConverter.ToUInt16(bytes, 3); this.Width = (int)BitConverter.ToUInt16(bytes, 5); this.Height = (int)BitConverter.ToUInt16(bytes, 7); this.CellWidth = (int)bytes[9]; this.CellHeight = (int)bytes[10]; this.ForegroundColorIndex = (int)bytes[11]; this.BackgroundColorIndex = (int)bytes[12]; this.Text = GifHelpers.GetString(await GifHelpers.ReadDataBlocksAsync(stream, false).ConfigureAwait(false)); this.Extensions = (IList <GifExtension>)controlExtensions.ToList <GifExtension>().AsReadOnly(); }