private static GifControlDirectory ReadControlBlock(SequentialReader reader)
        {
            var directory = new GifControlDirectory();

            byte packedFields = reader.GetByte();

            directory.Set(GifControlDirectory.TagDisposalMethod, (packedFields >> 2) & 7);
            directory.Set(GifControlDirectory.TagUserInputFlag, (packedFields & 2) == 2);
            directory.Set(GifControlDirectory.TagTransparentColorFlag, (packedFields & 1) == 1);
            directory.Set(GifControlDirectory.TagDelay, reader.GetUInt16());
            directory.Set(GifControlDirectory.TagTransparentColorIndex, reader.GetByte());

            // skip 0x0 block terminator
            reader.Skip(1);

            return(directory);
        }
Beispiel #2
0
        private static GifControlDirectory ReadControlBlock(SequentialReader reader, byte blockSizeBytes)
        {
            if (blockSizeBytes < 4)
            {
                blockSizeBytes = 4;
            }

            var directory = new GifControlDirectory();

            reader.Skip(1);

            directory.Set(GifControlDirectory.TagDelay, reader.GetUInt16());

            if (blockSizeBytes > 3)
            {
                reader.Skip(blockSizeBytes - 3);
            }

            // skip 0x0 block terminator
            reader.GetByte();

            return(directory);
        }