예제 #1
0
        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();
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
 private void Read(Stream stream, bool metadataOnly)
 {
     LzwMinimumCodeSize = (byte)stream.ReadByte();
     CompressedData     = GifHelpers.ReadDataBlocks(stream, metadataOnly);
 }