internal void Read(GifReader reader)
        {
            Byte size = reader.ReadByte();

            if (size != 4)
            {
                System.Diagnostics.Debug.WriteLine("Wrong size of " + ToString());
            }

            Byte flags = reader.ReadByte();

            disposalMethod    = (GifDisposalMethod)((flags & 0x1C) >> 2);
            userInputExpected = 0x02 == (flags & 0x02);
            transparency      = 0x01 == (flags & 0x01);

            delay             = reader.ReadUInt16();
            transparencyIndex = reader.ReadByte();

            Byte terminator = reader.ReadByte();

            if (terminator != 0x00)
            {
                throw new Exception("Unknown extension terminator: 0x" + terminator.ToString("X2"));
            }
        }
        internal void Read(GifReader reader)
        {
            width  = reader.ReadUInt16();
            height = reader.ReadUInt16();

            Byte flags = reader.ReadByte();

            globalColorTableFlag   = 0x80 == (flags & 0x80);
            colorResolution        = (Byte)(((flags & 0x70) >> 4) + 1);
            globalColorTableSorted = 0x08 == (flags & 0x08);
            globalColorTableSize   = (UInt16)(2 << (flags & 0x07));

            backgroundColorIndex = reader.ReadByte();
            pixelAspectRatio     = reader.ReadByte();
        }
Пример #3
0
        internal void Read(GifReader reader)
        {
            Byte size = reader.ReadByte();

            if (size != 12)
            {
                System.Diagnostics.Debug.WriteLine("Wrong size of " + ToString());
            }

            left   = reader.ReadUInt16();
            top    = reader.ReadUInt16();
            width  = reader.ReadUInt16();
            height = reader.ReadUInt16();

            cellWidth  = reader.ReadByte();
            cellHeight = reader.ReadByte();

            foregroundColor = reader.ReadByte();
            backgroundColor = reader.ReadByte();

            text = reader.ReadTextSubBlocks();
        }
Пример #4
0
        internal void Read(GifReader reader)
        {
            Byte size = reader.ReadByte();

            if (size != 11)
            {
                System.Diagnostics.Debug.WriteLine("Wrong size of " + ToString());
            }

            applicationIdentifier         = reader.ReadString(8);
            applicationAuthenticationCode = reader.ReadString(3);

            bytes = reader.ReadBinarySubBlocks();
        }
Пример #5
0
        internal void Read(GifReader reader)
        {
            left = reader.ReadUInt16();
            top  = reader.ReadUInt16();

            width  = reader.ReadUInt16();
            height = reader.ReadUInt16();

            Byte flags = reader.ReadByte();

            localColorTableFlag   = 0x80 == (flags & 0x80);
            interlaced            = 0x40 == (flags & 0x40);
            localColorTableSorted = 0x20 == (flags & 0x20);
            localColorTableSize   = (UInt16)(2 << (flags & 0x07));
        }
Пример #6
0
        internal void Read(GifReader reader)
        {
            lzwMinimumCodeSize = reader.ReadByte();

            imageData = reader.ReadBinarySubBlocks();
        }
Пример #7
0
        public void Read(Stream stream)
        {
            blocks.Clear();

            // reader

            GifReader reader = new GifReader(stream);

            // Header

            AddBlock(new GifHeaderBlock(reader));

            // Logical Screen Descriptor

            GifLogicalScreenDescriptorBlock gifLogicalScreenDescriptorBlock = new GifLogicalScreenDescriptorBlock(reader);

            AddBlock(gifLogicalScreenDescriptorBlock);

            // Global Color Table

            if (gifLogicalScreenDescriptorBlock.GlobalColorTableFlag)
            {
                AddBlock(new GifGlobalColorTableBlock(reader, gifLogicalScreenDescriptorBlock));
            }

            // Segments

            while (true)
            {
                Byte identifier = reader.ReadByte();
                switch (identifier)
                {
                // Frames

                case 0x2C:
                    GifImageDescriptorBlock gifImageDescriptorBlock = new GifImageDescriptorBlock(reader);
                    AddBlock(gifImageDescriptorBlock);

                    if (gifImageDescriptorBlock.LocalColorTableFlag)
                    {
                        AddBlock(new GifLocalColorTableBlock(reader, gifImageDescriptorBlock));
                    }

                    AddBlock(new GifTableBasedImageDataBlock(reader));
                    break;

                // Extensions

                case 0x21:
                    Byte label = reader.ReadByte();

                    switch (label)
                    {
                    case 0xF9:
                        AddBlock(new GifGraphicControExtensionBlock(reader));
                        break;

                    case 0xFE:
                        AddBlock(new GifCommentExtensionBlock(reader));
                        break;

                    case 0x01:
                        AddBlock(new GifPlainTextExtensionBlock(reader));
                        break;

                    case 0xFF:
                        AddBlock(GifApplicationExtensionBlock.Create(reader));
                        break;

                    default:
                        AddBlock(new GifExtensionBlock(label, reader));
                        break;
                    }
                    break;

                // Trailer

                case 0x3B:
                    AddBlock(new GifTrailerBlock());
                    return;

                default:
                    throw new Exception("Unknown segment identifier: 0x" + identifier.ToString("X2"));
                }
            }
        }