internal void ReadImageDescriptorFromFile(BinaryReader reader, GifGraphicsControlExtension extensionOrNull) { _extensionOrNull = extensionOrNull; _bounds.X = (int)reader.ReadUInt16(); _bounds.Y = (int)reader.ReadUInt16(); _bounds.Width = (int)reader.ReadUInt16(); _bounds.Height = (int)reader.ReadUInt16(); byte flags = reader.ReadByte(); bool hasLocalColourTable = (flags & 0x80) != 0; _isInterlaced = (flags & 0x40) != 0; _isSorted = (flags & 0x20) != 0; int sizeOfLocalColourTable = 1 << (1 + (flags & 0x07)); if (hasLocalColourTable) { _colourTable = new GifColourTable(); _colourTable.ReadFromFile(reader, sizeOfLocalColourTable); } else { _colourTable = null; } ReadImageDataFromFile(reader); }
public GifFrame() { _bounds = new Rectangle(); _colourTable = null; _subBlocks = null; _extensionOrNull = null; }
void ReadBlocksFromFile(BinaryReader reader) { GifGraphicsControlExtension capturedExtension = null; while (true) { byte blockType = reader.ReadByte(); byte extensionType; switch (blockType) { case GifConstants.ImageDescriptorLabel: GifFrame frame = new GifFrame(); frame.ReadImageDescriptorFromFile(reader, capturedExtension); _frames.Add(frame); capturedExtension = null; break; case GifConstants.FileTerminatorLabel: return; case GifConstants.ExtensionLabel: extensionType = reader.ReadByte(); switch (extensionType) { case GifConstants.GraphicsControlExtensionSubLabel: capturedExtension = new GifGraphicsControlExtension(); capturedExtension.ReadFromFile(reader); break; default: ReadUnknownBlockFromFile(reader, true); break; } ReadBlockTerminatorFromFile(reader); break; default: ReadUnknownBlockFromFile(reader, false); ReadBlockTerminatorFromFile(reader); break; } } }