PHP生成Gif图片验证码(4)

private static function AddFrames($i, $d) {
        $L_str = 13 + 3 * (2 << (ord(self::$BUF[$i]{10}) & 0x07));
        $L_end = strlen(self::$BUF[$i]) - $L_str - 1;
        $L_tmp = substr(self::$BUF[$i], $L_str, $L_end);
        $G_len = 2 << (ord(self::$BUF[0]{10}) & 0x07);
        $L_len = 2 << (ord(self::$BUF[$i]{10}) & 0x07);
        $G_rgb = substr(self::$BUF[0], 13, 3 * (2 << (ord(self::$BUF[0]{10}) & 0x07)));
        $L_rgb = substr(self::$BUF[$i], 13, 3 * (2 << (ord(self::$BUF[$i]{10}) & 0x07)));
        $L_ext = "!\xF9\x04" . chr((self::$DIS << 2) + 0) . chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . "\x0\x0";
        if (self::$COL > -1 && ord(self::$BUF[$i]{10}) & 0x80) {
            for ($j = 0; $j < (2 << (ord(self::$BUF[$i]{10}) & 0x07)); $j++) {
                if (ord($L_rgb{3 * $j + 0}) == (self::$COL >> 0) & 0xFF && ord($L_rgb{3 * $j + 1}) == (self::$COL >> 8) & 0xFF && ord($L_rgb{3 * $j + 2}) == (self::$COL >> 16) & 0xFF) {
                    $L_ext = "!\xF9\x04" . chr((self::$DIS << 2) + 1) . chr(($d >> 0) & 0xFF) . chr(($d >> 8) & 0xFF) . chr($j) . "\x0";
                    break;
                }
            }
        }
        switch ($L_tmp{0}) {
            case '!':
                $L_img = substr($L_tmp, 8, 10);
                $L_tmp = substr($L_tmp, 18, strlen($L_tmp) - 18);
                break;
            case ',':
                $L_img = substr($L_tmp, 0, 10);
                $L_tmp = substr($L_tmp, 10, strlen($L_tmp) - 10);
                break;
        }
        if (ord(self::$BUF[$i]{10}) & 0x80 && self::$IMG > -1) {
            if ($G_len == $L_len) {
                if (self::Compare($G_rgb, $L_rgb, $G_len)) {
                    self::$Img .= ($L_ext . $L_img . $L_tmp);
                } else {
                    $byte = ord($L_img{9});
                    $byte |= 0x80;
                    $byte &= 0xF8;
                    $byte |= (ord(self::$BUF[0]{10}) & 0x07);
                    $L_img{9} = chr($byte);
                    self::$Img .= ($L_ext . $L_img . $L_rgb . $L_tmp);
                }
            } else {
                $byte = ord($L_img{9});
                $byte |= 0x80;
                $byte &= 0xF8;
                $byte |= (ord(self::$BUF[$i]{10}) & 0x07);
                $L_img{9} = chr($byte);
                self::$Img .= ($L_ext . $L_img . $L_rgb . $L_tmp);
            }
        } else {
            self::$Img .= ($L_ext . $L_img . $L_tmp);
        }
        self::$IMG = 1;
    }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/7bf30abdf9c3d6152834b297762c3169.html