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); }
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) { 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(); }
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)); }
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(); }
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; //} }
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); } }
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(); }
internal void Read(GifReader reader) { bytes = reader.ReadBinarySubBlocks(); }
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")); } } }
internal GifExtensionBlock(Byte label, GifReader reader) : base(GifBlockType.Extension) { this.label = label; Read(reader); }
internal GifApplicationExtensionBlock(GifReader reader) : base(GifBlockType.ApplicationExtension) { Read(reader); }
internal GifLogicalScreenDescriptorBlock(GifReader reader) : base(GifBlockType.LogicalScreenDescriptor) { Read(reader); }
internal GifCommentExtensionBlock(GifReader reader) : base(GifBlockType.CommentExtension) { Read(reader); }
internal GifImageDescriptorBlock(GifReader reader) : base(GifBlockType.ImageDescriptor) { Read(reader); }
internal GifGraphicControExtensionBlock(GifReader reader) : base(GifBlockType.GraphicControlExtension) { Read(reader); }
internal void Read(GifReader reader) { comment = reader.ReadTextSubBlocks(); }
internal GifLocalColorTableBlock(GifReader reader, GifImageDescriptorBlock gifImageDescriptorBlock) : base(GifBlockType.LocalColorTable) { Read(reader, gifImageDescriptorBlock); }
internal GifHeaderBlock(GifReader reader) : base(GifBlockType.Header) { Read(reader); }
internal void Read(GifReader reader) { lzwMinimumCodeSize = reader.ReadByte(); imageData = reader.ReadBinarySubBlocks(); }
internal GifTableBasedImageDataBlock(GifReader reader) : base(GifBlockType.TableBasedImageData) { Read(reader); }
internal void Read(GifReader reader, GifImageDescriptorBlock gifImageDescriptorBlock) { bytes = reader.ReadBytes(gifImageDescriptorBlock.LocalColorTableSize * 3); }
internal GifPlainTextExtensionBlock(GifReader reader) : base(GifBlockType.PlainTextExtension) { Read(reader); }
internal GifGlobalColorTableBlock(GifReader reader, GifLogicalScreenDescriptorBlock gifLogicalScreenDescriptorBlock) : base(GifBlockType.GlobalColorTable) { Read(reader, gifLogicalScreenDescriptorBlock); }