コード例 #1
0
        internal static GifApplicationExtensionBlock Create(GifReader reader)
        {
            GifApplicationExtensionBlock gifApplicationExtensionBlock = new GifApplicationExtensionBlock(reader);

            if (gifApplicationExtensionBlock.ApplicationIdentifier.Equals("NETSCAPE") && gifApplicationExtensionBlock.ApplicationAuthenticationCode.Equals("2.0"))
            {
                if ((null != gifApplicationExtensionBlock.Bytes))
                {
                    if ((3 == gifApplicationExtensionBlock.Bytes.Length) && (1 == gifApplicationExtensionBlock.Bytes[0]))
                    {
                        gifApplicationExtensionBlock = new GifNetscapeLoopingApplicationExtensionBlock(gifApplicationExtensionBlock);
                    }
                    else if ((5 == gifApplicationExtensionBlock.Bytes.Length) && (2 == gifApplicationExtensionBlock.Bytes[0]))
                    {
                        gifApplicationExtensionBlock = new GifNetscapeBufferingApplicationExtensionBlock(gifApplicationExtensionBlock);
                    }
                }
            }
            else if (gifApplicationExtensionBlock.ApplicationIdentifier.Equals("ANIMEXTS") && gifApplicationExtensionBlock.ApplicationAuthenticationCode.Equals("1.0"))
            {
                if ((null != gifApplicationExtensionBlock.Bytes) && (3 == gifApplicationExtensionBlock.Bytes.Length) && (1 == gifApplicationExtensionBlock.Bytes[0]))
                {
                    gifApplicationExtensionBlock = new GifAnimextsLoopingApplicationExtensionBlock(gifApplicationExtensionBlock);
                }
            }

            return(gifApplicationExtensionBlock);
        }
コード例 #2
0
        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"));
            }
        }
コード例 #3
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();
        }
コード例 #4
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));
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        internal void Read(GifReader reader, GifLogicalScreenDescriptorBlock gifLogicalScreenDescriptorBlock)
        {
            bytes = reader.ReadBytes(gifLogicalScreenDescriptorBlock.GlobalColorTableSize * 3);

            //byte[] globalColorTableBuffer = reader.ReadBytes(globalColorTableSize * 3);

            //globalColorTable = new Color[globalColorTableSize];

            //int baseIndex = 0;
            //for (UInt16 colorIndex = 0; colorIndex < globalColorTableSize; colorIndex++)
            //{
            //    globalColorTable[colorIndex] = Color.FromArgb(globalColorTableBuffer[baseIndex], globalColorTableBuffer[baseIndex + 1], globalColorTableBuffer[baseIndex + 2]);
            //    baseIndex += 3;
            //}
        }
コード例 #7
0
ファイル: GifHeaderBlock.cs プロジェクト: zys529/abandoned
        internal void Read(GifReader reader)
        {
            String signature = reader.ReadString(3);

            if (signature != "GIF")
            {
                throw new Exception("No GIF signature");
            }

            version = reader.ReadString(3);
            if ((version != "87a") && (version != "89a"))
            {
                throw new Exception("Unsupported GIF version: " + version);
            }
        }
コード例 #8
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();
        }
コード例 #9
0
ファイル: GifExtensionBlock.cs プロジェクト: zys529/abandoned
 internal void Read(GifReader reader)
 {
     bytes = reader.ReadBinarySubBlocks();
 }
コード例 #10
0
ファイル: GifImage.cs プロジェクト: zys529/abandoned
        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"));
                }
            }
        }
コード例 #11
0
ファイル: GifExtensionBlock.cs プロジェクト: zys529/abandoned
 internal GifExtensionBlock(Byte label, GifReader reader)
     : base(GifBlockType.Extension)
 {
     this.label = label;
     Read(reader);
 }
コード例 #12
0
 internal GifApplicationExtensionBlock(GifReader reader)
     : base(GifBlockType.ApplicationExtension)
 {
     Read(reader);
 }
コード例 #13
0
 internal GifLogicalScreenDescriptorBlock(GifReader reader)
     : base(GifBlockType.LogicalScreenDescriptor)
 {
     Read(reader);
 }
コード例 #14
0
 internal GifCommentExtensionBlock(GifReader reader)
     : base(GifBlockType.CommentExtension)
 {
     Read(reader);
 }
コード例 #15
0
 internal GifImageDescriptorBlock(GifReader reader)
     : base(GifBlockType.ImageDescriptor)
 {
     Read(reader);
 }
コード例 #16
0
 internal GifGraphicControExtensionBlock(GifReader reader)
     : base(GifBlockType.GraphicControlExtension)
 {
     Read(reader);
 }
コード例 #17
0
 internal void Read(GifReader reader)
 {
     comment = reader.ReadTextSubBlocks();
 }
コード例 #18
0
 internal GifLocalColorTableBlock(GifReader reader, GifImageDescriptorBlock gifImageDescriptorBlock)
     : base(GifBlockType.LocalColorTable)
 {
     Read(reader, gifImageDescriptorBlock);
 }
コード例 #19
0
ファイル: GifHeaderBlock.cs プロジェクト: zys529/abandoned
 internal GifHeaderBlock(GifReader reader)
     : base(GifBlockType.Header)
 {
     Read(reader);
 }
コード例 #20
0
        internal void Read(GifReader reader)
        {
            lzwMinimumCodeSize = reader.ReadByte();

            imageData = reader.ReadBinarySubBlocks();
        }
コード例 #21
0
 internal GifTableBasedImageDataBlock(GifReader reader)
     : base(GifBlockType.TableBasedImageData)
 {
     Read(reader);
 }
コード例 #22
0
 internal void Read(GifReader reader, GifImageDescriptorBlock gifImageDescriptorBlock)
 {
     bytes = reader.ReadBytes(gifImageDescriptorBlock.LocalColorTableSize * 3);
 }
コード例 #23
0
 internal GifPlainTextExtensionBlock(GifReader reader)
     : base(GifBlockType.PlainTextExtension)
 {
     Read(reader);
 }
コード例 #24
0
 internal GifGlobalColorTableBlock(GifReader reader, GifLogicalScreenDescriptorBlock gifLogicalScreenDescriptorBlock)
     : base(GifBlockType.GlobalColorTable)
 {
     Read(reader, gifLogicalScreenDescriptorBlock);
 }