private function decodeImageDescriptor(Decoded $gif)
    {
        $descriptor = $this->getNextBytes(9);

        // determine if descriptor has local color table
        $flag = substr($descriptor, 8, 1);
        $flag = unpack('C', $flag)[1];
        $flag = (bool) ($flag & bindec('10000000'));
        if ($flag) {
            // read local color table
            $byte = substr($descriptor, 8, 1);
            $byte = unpack('C', $byte)[1];
            $size = (int) ($byte & bindec('00000111'));
            $size = 3 * pow(2, $size + 1);
            
            $gif->addLocalColorTable($this->getNextBytes($size));

        } else {
            $gif->addLocalColorTable(null);
        }

        // determine if image is marked as interlaced
        $interlaced = substr($descriptor, 8, 1);
        $interlaced = unpack('C', $interlaced)[1];
        $interlaced = (bool) ($interlaced & bindec('01000000'));
        $gif->addInterlaced($interlaced);

        // decode image offsets
        $left = substr($descriptor, 0, 2);
        $left = unpack('C', $left)[1];
        $top = substr($descriptor, 2, 2);
        $top = unpack('C', $top)[1];
        $gif->addOffset($left, $top);

        // decode image dimensions
        $width = substr($descriptor, 4, 2);
        $width = unpack('v', $width)[1];
        $height = substr($descriptor, 6, 2);
        $height = unpack('v', $height)[1];
        $gif->addSize($width, $height);

        $gif->addImageDescriptors($descriptor);
    }