Beispiel #1
0
        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();
        }
Beispiel #2
0
        private async Task ReadInternalAsync(Stream stream)
        {
            byte[] bytes = await GifHelpers.ReadDataBlocksAsync(stream, false).ConfigureAwait(false);

            if (bytes == null)
            {
                return;
            }
            this.Text = GifHelpers.GetString(bytes);
        }
Beispiel #3
0
        private async Task ReadInternalAsync(Stream stream)
        {
            // Note: at this point, the label (0xFE) has already been read

            var bytes = await GifHelpers.ReadDataBlocksAsync(stream).ConfigureAwait(false);

            if (bytes != null)
            {
                Text = GifHelpers.GetString(bytes);
            }
        }
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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();
        }
 private async Task ReadInternalAsync(Stream stream)
 {
     LzwMinimumCodeSize        = (byte)stream.ReadByte();
     CompressedDataStartOffset = stream.Position;
     await GifHelpers.ReadDataBlocksAsync(stream, true).ConfigureAwait(false);
 }