private void Read(Stream stream, IEnumerable <GifExtension> controlExtensions, bool metadataOnly) { // Note: at this point, the label (0x01) has already been read byte[] bytes = new byte[13]; stream.ReadAll(bytes, 0, bytes.Length); 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 = GifHelpers.ReadDataBlocks(stream, metadataOnly); Text = Encoding.ASCII.GetString(dataBytes); Extensions = controlExtensions.ToList().AsReadOnly(); }
private void Read(Stream stream) { byte[] bytes = GifHelpers.ReadDataBlocks(stream, false); if (bytes != null) { this.Text = Encoding.ASCII.GetString(bytes); } }
private void Read(Stream stream) { // Note: at this point, the label (0xFE) has already been read var bytes = GifHelpers.ReadDataBlocks(stream, false); if (bytes != null) { Text = Encoding.ASCII.GetString(bytes); } }
private void Read(Stream stream) { byte[] buffer = new byte[12]; stream.ReadAll(buffer, 0, buffer.Length); this.BlockSize = buffer[0]; if (this.BlockSize != 11) { throw GifHelpers.InvalidBlockSizeException("Application Extension", 11, this.BlockSize); } this.ApplicationIdentifier = Encoding.ASCII.GetString(buffer, 1, 8); byte[] destinationArray = new byte[3]; Array.Copy(buffer, 9, destinationArray, 0, 3); this.AuthenticationCode = destinationArray; this.Data = GifHelpers.ReadDataBlocks(stream, false); }
private void Read(Stream stream) { // Note: at this point, the label (0xFF) has already been read byte[] bytes = new byte[12]; stream.ReadAll(bytes, 0, bytes.Length); BlockSize = bytes[0]; // should always be 11 if (BlockSize != 11) { throw GifHelpers.InvalidBlockSizeException("Application Extension", 11, BlockSize); } ApplicationIdentifier = Encoding.ASCII.GetString(bytes, 1, 8); byte[] authCode = new byte[3]; Array.Copy(bytes, 9, authCode, 0, 3); AuthenticationCode = authCode; Data = GifHelpers.ReadDataBlocks(stream, false); }
private void Read(Stream stream, IEnumerable <GifExtension> controlExtensions, bool metadataOnly) { byte[] buffer = new byte[13]; stream.ReadAll(buffer, 0, buffer.Length); this.BlockSize = buffer[0]; if (this.BlockSize != 12) { throw GifHelpers.InvalidBlockSizeException("Plain Text Extension", 12, this.BlockSize); } this.Left = BitConverter.ToUInt16(buffer, 1); this.Top = BitConverter.ToUInt16(buffer, 3); this.Width = BitConverter.ToUInt16(buffer, 5); this.Height = BitConverter.ToUInt16(buffer, 7); this.CellWidth = buffer[9]; this.CellHeight = buffer[10]; this.ForegroundColorIndex = buffer[11]; this.BackgroundColorIndex = buffer[12]; byte[] bytes = GifHelpers.ReadDataBlocks(stream, metadataOnly); this.Text = Encoding.ASCII.GetString(bytes); this.Extensions = controlExtensions.ToList <GifExtension>().AsReadOnly(); }
private void Read(Stream stream, bool metadataOnly) { this.LzwMinimumCodeSize = (byte)stream.ReadByte(); this.CompressedData = GifHelpers.ReadDataBlocks(stream, metadataOnly); }