代码如下所示:
class GifMerge {
var $ver = '1.1';
var $dly = 50;
var $mod = 'C_FILE';
var $first = true;
var $use_loop = false;
var $transparent = false;
var $use_global_in = false;
var $x = 0;
var $y = 0;
var $ch = 0;
var $fin = 0;
var $fout = '';
var $loop = 0;
var $delay = 0;
var $width = 0;
var $height = 0;
var $trans1 = 255;
var $trans2 = 255;
var $trans3 = 255;
var $disposal = 2;
var $out_color_table_size = 0;
var $local_color_table_flag = 0;
var $global_color_table_size = 0;
var $out_color_table_sizecode = 0;
var $global_color_table_sizecode= 0;
var $gif = array(0x47, 0x49, 0x46);
var $buffer = array();
var $local_in = array();
var $global_in = array();
var $global_out = array();
var $logical_screen_descriptor = array();
function GifMerge($images, $t1, $t2, $t3, $loop, $dl, $xpos, $ypos, $model) {
if($model) {
$this->mod = $model;
}
if($loop > -1) {
$this->loop = floor($loop - 1);
$this->use_loop = true;
}
if($t1 > -1 && $t2 > -1 && $t3 > -1) {
$this->trans1 = $t1;
$this->trans2 = $t2;
$this->trans3 = $t3;
$this->transparent = true;
}
for($i = 0; $i $dl[$i] ? $this->delay = $dl[$i] : $this->delay = $this->dly;
$xpos[$i] ? $this->x = $xpos[$i] : $this->x = 0;
$ypos[$i] ? $this->y = $ypos[$i] : $this->y = 0;
$this->start_gifmerge_process($images[$i]);
}
$this->fout .= "/x3b";
}
function start_gifmerge_process($fp) {
if($this->mod == 'C_FILE') {
if(!$this->fin = fopen($fp, 'rb')) {
return;
}
} elseif($this->mod == 'C_MEMORY') {
$this->ch = 0;
$this->fin = $fp;
}
$this->getbytes(6);
if(!$this->arrcmp($this->buffer, $this->gif, 3)) {
return;
}
$this->getbytes(7);
if($this->first) $this->logical_screen_descriptor = $this->buffer;
$this->global_color_table_sizecode = $this->buffer[4] & 0x07;
$this->global_color_table_size = 2 global_color_table_sizecode;
if($this->buffer[4] & 0x80) {
$this->getbytes((3 * $this->global_color_table_size));
for($i = 0; $i global_color_table_size)); $i++) {
$this->global_in[$i] = $this->buffer[$i];
}
if($this->out_color_table_size == 0) {
$this->out_color_table_size = $this->global_color_table_size;
$out_color_table_sizecode = $this->global_color_table_sizecode;
$this->global_out = $this->global_in;
}
if($this->global_color_table_size != $this->out_color_table_size || $this->arrcmp($this->global_out, $this->global_in, (3 * $this->global_color_table_size))) {
$this->use_global_in = true;
}
}
for($loop = true; $loop;) {
$this->getbytes(1);
switch($this->buffer[0]) {
case 0x21:
$this->read_extension();
break;
case 0x2c:
$this->read_image_descriptor();
break;
case 0x3b:
$loop = false;
break;
default:
$loop = false;
}
}
if($this->mod == 'C_FILE') {
fclose($this->fin);
}
}
function read_image_descriptor() {
$this->getbytes(9);
$head = $this->buffer;
$this->local_color_table_flag = ($this->buffer[8] & 0x80) ? true : false;
if($this->local_color_table_flag) {
$sizecode = $this->buffer[8] & 0x07;
$size = 2 $this->getbytes(3 * $size);
for($i = 0; $i $this->local_in[$i] = $this->buffer[$i];
}
if($this->out_color_table_size == 0) {
$this->out_color_table_size = $size;
$out_color_table_sizecode = $sizecode;
for($i = 0; $i {
$this->global_out[$i] = $this->local_in[$i];
}
}
}
if($this->first) {
$this->first = false;
$this->fout .= "/x47/x49/x46/x38/x39/x61";
if($this->width && $this->height) {
$this->logical_screen_descriptor[0] = $this->width & 0xFF;
$this->logical_screen_descriptor[1] = ($this->width & 0xFF00) >> 8;
$this->logical_screen_descriptor[2] = $this->height & 0xFF;
$this->logical_screen_descriptor[3] = ($this->height & 0xFF00) >> 8;
}
$this->logical_screen_descriptor[4] |= 0x80;
$this->logical_screen_descriptor[5] &= 0xF0;
$this->logical_screen_descriptor[6] |= $this->out_color_table_sizecode;
$this->putbytes($this->logical_screen_descriptor, 7);
$this->putbytes($this->global_out, ($this->out_color_table_size * 3));
if($this->use_loop) {
$ns[0] = 0x21;
$ns[1] = 0xFF;
$ns[2] = 0x0B;
$ns[3] = 0x4e;
$ns[4] = 0x45;
$ns[5] = 0x54;
$ns[6] = 0x53;
$ns[7] = 0x43;
$ns[8] = 0x41;
$ns[9] = 0x50;
$ns[10] = 0x45;
$ns[11] = 0x32;
$ns[12] = 0x2e;
$ns[13] = 0x30;
$ns[14] = 0x03;
$ns[15] = 0x01;
$ns[16] = $this->loop & 255;
$ns[17] = $this->loop >> 8;
$ns[18] = 0x00;
$this->putbytes($ns, 19);
}
}
if($this->use_global_in) {
$outtable = $this->global_in;
$outsize = $this->global_color_table_size;
$outsizecode = $this->global_color_table_sizecode;
} else {
$outtable = $this->global_out;
$outsize = $this->out_color_table_size;
}
if($this->local_color_table_flag) {
if($size == $this->out_color_table_size && !$this->arrcmp($this->local_in, $this->global_out, $size)) {
$outtable = $global_out;
$outsize = $this->out_color_table_size;
} else {
$outtable = $this->local_in;
$outsize = $size;
$outsizecode = $sizecode;
}
}
$use_trans = false;
if($this->transparent) {
for($i = 0; $i if($outtable[3 * $i] == $this->trans1 && $outtable [3 * $i + 1] == $this->trans2 && $outtable [3 * $i + 2] == $this->trans3) {
break;
}
}
if($i $transindex = $i;
$use_trans = true;
}
}
if($this->delay || $use_trans) {
$this->buffer[0] = 0x21;
$this->buffer[1] = 0xf9;
$this->buffer[2] = 0x04;
$this->buffer[3] = ($this->disposal $this->buffer[4] = $this->delay & 0xff;
$this->buffer[5] = ($this->delay & 0xff00) >> 8;
$this->buffer[6] = $use_trans ? $transindex : 0;
$this->buffer[7] = 0x00;
$this->putbytes($this->buffer,8);
}
$this->buffer[0] = 0x2c;
$this->putbytes($this->buffer,1);
$head[0] = $this->x & 0xff;
$head[1] = ($this->x & 0xff00) >> 8;
$head[2] = $this->y & 0xff;
$head[3] = ($this->y & 0xff00) >> 8;
$head[8] &= 0x40;
if($outtable != $this->global_out) {
$head[8] |= 0x80;
$head[8] |= $outsizecode;
}
$this->putbytes($head,9);
if($outtable != $this->global_out) {
$this->putbytes($outtable, (3 * $outsize));
}
$this->getbytes(1);
$this->putbytes($this->buffer,1);
for(;;) {
$this->getbytes(1);
$this->putbytes($this->buffer,1);
if(($u = $this->buffer[0]) == 0) {
break;
}
$this->getbytes($u);
$this->putbytes($this->buffer, $u);
}
}
function read_extension() {
$this->getbytes(1);
switch($this->buffer[0]) {
case 0xf9:
$this->getbytes(6);
break;
case 0xfe:
for(;;) {
$this->getbytes(1);
if(($u = $this->buffer[0]) == 0) {
break;
}
$this->getbytes($u);
}
break;
case 0x01:
$this->getbytes(13);
for(;;) {
$this->getbytes(0);
if(($u = $this->buffer[0]) == 0) {
break;
}
$this->getbytes($u);
}
break;
case 0xff:
$this->getbytes(9);
$this->getbytes(3);
for(;;) {
$this->getbytes(1);
if(!$this->buffer[0]) {
break;
}
$this->getbytes($this->buffer[0]);
}
break;
default:
for(;;) {
$this->getbytes(1);
if(!$this->buffer[0]) {
break;
}
$this->getbytes($this->buffer[0]);
}
}
}
function arrcmp($b, $s, $l) {
for($i = 0; $i if($s{$i} != $b{$i}) {
return false;
}
}
return true;
}
function getbytes($l) {
for($i = 0; $i if($this->mod == 'C_FILE') {
$bin = unpack('C*', fread($this->fin, 1));
$this->buffer[$i] = $bin[1];
} elseif($this->mod == 'C_MEMORY') {
$bin = unpack('C*', substr($this->fin, $this->ch, 1));
$this->buffer[$i] = $bin[1];
$this->ch++;
}
}
return $this->buffer;
}
function putbytes($s, $l) {
for($i = 0; $i $this->fout .= pack('C*', $s[$i]);
}
}
function getAnimation() {
return $this->fout;
}
}
?>

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

Dreamweaver Mac版
视觉化网页开发工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。