可以做动漫网站的源码分享源码分享 移动端动漫网站源码

大家好,今天来为大家分享可以做动漫网站的源码分享源码分享的一些知识点,和移动端动漫网站源码的问题解析,大家要是都明白,那么可以忽略,如果不太清楚的话可以看看本篇文章,相信很大概率可以解决您的问题,接下来我们就一起来看看吧!

各位朋友,大家下午好!

今天给大家带来的教学是轻松创建gif图在线制作网站!

这里就需要用到一个GIF动画的PHP类库!

下面我把类库代码分享给大家

由于源码比较长,需要的朋友可以私聊小编哦!

废话不多说,上源码!

<?php

namespaceGifCreator;

/**

*CreateananimatedGIFfrommultipleimages

*

*@version1.0

*@linkhttps://github.com/Sybio/GifCreator

*@authorSybio(ClémentGuillemain/@Sybio01)

*@licensehttp://opensource.org/licenses/gpl-license.phpGNUPublicLicense

*@copyrightClémentGuillemain

*/

classGifCreator

{

/**

*@varstringThegifstringsource(old:this->GIF)

*/

private$gif;

/**

*@varstringEncoderversion(old:this->VER)

*/

private$version;

/**

*@varbooleanChecktheimageisbuildornot(old:this->IMG)

*/

private$imgBuilt;

/**

*@vararrayFramesstringsources(old:this->BUF)

*/

private$frameSources;

/**

*@varintegerGifloop(old:this->LOP)

*/

private$loop;

/**

*@varintegerGifdis(old:this->DIS)

*/

private$dis;

/**

*@varintegerGifcolor(old:this->COL)

*/

private$colour;

/**

*@vararray(old:this->ERR)

*/

private$errors;

//Methods

//===================================================================================

/**

*Constructor

*/

publicfunction__construct()

{

$this->reset();

//Staticdata

$this->version=’GifCreator:Underdevelopment’;

$this->errors=array(

‘ERR00’=>’Doesnotsupportedfunctionforonlyoneimage.’,

‘ERR01’=>’SourceisnotaGIFimage.’,

‘ERR02’=>’Youhavetogiveresourceimagevariables,imageURLorimagebinarysourcesin$framesarray.’,

‘ERR03’=>’DoesnotmakeanimationfromanimatedGIFsource.’,

);

}

/**

*CreatetheGIFstring(old:GIFEncoder)

*

*@paramarray$framesAnarrayofframe:canbefilepaths,resourceimagevariables,binarysourcesorimageURLs

*@paramarray$durationsAnarraycontainingthedurationofeachframe

*@paraminteger$loopNumberofGIFloopsbeforestoppinganimation(Set0togetaninfiniteloop)

*

*@returnstringTheGIFstringsource

*/

publicfunctioncreate($frames=array(),$durations=array(),$loop=0)

{

if(!is_array($frames)&&!is_array($GIF_tim)){

thrownew\\Exception($this->version.’:’.$this->errors[‘ERR00’]);

}

$this->loop=($loop>-1)?$loop:0;

$this->dis=2;

for($i=0;$i<count($frames);$i++){

if(is_resource($frames[$i])){//Resourcevar

$resourceImg=$frames[$i];

ob_start();

imagegif($frames[$i]);

$this->frameSources[]=ob_get_contents();

ob_end_clean();

}elseif(is_string($frames[$i])){//FilepathorURLorBinarysourcecode

if(file_exists($frames[$i])||filter_var($frames[$i],FILTER_VALIDATE_URL)){//Filepath

$frames[$i]=file_get_contents($frames[$i]);

}

$resourceImg=imagecreatefromstring($frames[$i]);

ob_start();

imagegif($resourceImg);

$this->frameSources[]=ob_get_contents();

ob_end_clean();

}else{//Fail

thrownew\\Exception($this->version.’:’.$this->errors[‘ERR02’].'(‘.$mode.’)’);

}

if($i==0){

$colour=imagecolortransparent($resourceImg);

}

if(substr($this->frameSources[$i],0,6)!=’GIF87a’&&substr($this->frameSources[$i],0,6)!=’GIF89a’){

thrownew\\Exception($this->version.’:’.$i.”.$this->errors[‘ERR01’]);

}

for($j=(13+3*(2<<(ord($this->frameSources[$i]{10})&0x07))),$k=TRUE;$k;$j++){

switch($this->frameSources[$i]{$j}){

case’!’:

if((substr($this->frameSources[$i],($j+3),8))==’NETSCAPE’){

thrownew\\Exception($this->version.’:’.$this->errors[‘ERR03’].'(‘.($i+1).’source).’);

}

break;

case’;’:

$k=false;

break;

}

}

unset($resourceImg);

}

if(isset($colour)){

$this->colour=$colour;

}else{

$red=$green=$blue=0;

$this->colour=($red>-1&&$green>-1&&$blue>-1)?($red|($green<<8)|($blue<<16)):-1;

}

$this->gifAddHeader();

for($i=0;$i<count($this->frameSources);$i++){

$this->addGifFrames($i,$durations[$i]);

}

$this->gifAddFooter();

return$this->gif;

}

//Internals

//===================================================================================

/**

*Addtheheadergifstringinitssource(old:GIFAddHeader)

*/

publicfunctiongifAddHeader()

{

$cmap=0;

if(ord($this->frameSources[0]{10})&0x80){

$cmap=3*(2<<(ord($this->frameSources[0]{10})&0x07));

$this->gif.=substr($this->frameSources[0],6,7);

$this->gif.=substr($this->frameSources[0],13,$cmap);

$this->gif.=”!\\377\\13NETSCAPE2.0\\3\\1″.$this->encodeAsciiToChar($this->loop).”\\0″;

}

}

/**

*AddtheframesourcestotheGIFstring(old:GIFAddFrames)

*

*@paraminteger$i

*@paraminteger$d

*/

publicfunctionaddGifFrames($i,$d)

{

$Locals_str=13+3*(2<<(ord($this->frameSources[$i]{10})&0x07));

$Locals_end=strlen($this->frameSources[$i])-$Locals_str-1;

$Locals_tmp=substr($this->frameSources[$i],$Locals_str,$Locals_end);

$Global_len=2<<(ord($this->frameSources[0]{10})&0x07);

$Locals_len=2<<(ord($this->frameSources[$i]{10})&0x07);

$Global_rgb=substr($this->frameSources[0],13,3*(2<<(ord($this->frameSources[0]{10})&0x07)));

$Locals_rgb=substr($this->frameSources[$i],13,3*(2<<(ord($this->frameSources[$i]{10})&0x07)));

$Locals_ext=”!\\xF9\\x04″.chr(($this->dis<<2)+0).chr(($d>>0)&0xFF).chr(($d>>8)&0xFF).”\\x0\\x0″;

if($this->colour>-1&&ord($this->frameSources[$i]{10})&0x80){

for($j=0;$j<(2<<(ord($this->frameSources[$i]{10})&0x07));$j++){

if(ord($Locals_rgb{3*$j+0})==(($this->colour>>16)&0xFF)&&

ord($Locals_rgb{3*$j+1})==(($this->colour>>8)&0xFF)&&

ord($Locals_rgb{3*$j+2})==(($this->colour>>0)&0xFF)

){

$Locals_ext=”!\\xF9\\x04″.chr(($this->dis<<2)+1).chr(($d>>0)&0xFF).chr(($d>>8)&0xFF).chr($j).”\\x0″;

break;

}

}

}

switch($Locals_tmp{0}){

case’!’:

$Locals_img=substr($Locals_tmp,8,10);

$Locals_tmp=substr($Locals_tmp,18,strlen($Locals_tmp)-18);

break;

case’,’:

$Locals_img=substr($Locals_tmp,0,10);

$Locals_tmp=substr($Locals_tmp,10,strlen($Locals_tmp)-10);

break;

}

if(ord($this->frameSources[$i]{10})&0x80&&$this->imgBuilt){

if($Global_len==$Locals_len){

if($this->gifBlockCompare($Global_rgb,$Locals_rgb,$Global_len)){

$this->gif.=$Locals_ext.$Locals_img.$Locals_tmp;

}else{

$byte=ord($Locals_img{9});

$byte|=0x80;

$byte&=0xF8;

$byte|=(ord($this->frameSources[0]{10})&0x07);

$Locals_img{9}=chr($byte);

$this->gif.=$Locals_ext.$Locals_img.$Locals_rgb.$Locals_tmp;

}

}else{

$byte=ord($Locals_img{9});

$byte|=0x80;

$byte&=0xF8;

$byte|=(ord($this->frameSources[$i]{10})&0x07);

$Locals_img{9}=chr($byte);

$this->gif.=$Locals_ext.$Locals_img.$Locals_rgb.$Locals_tmp;

}

}else{

$this->gif.=$Locals_ext.$Locals_img.$Locals_tmp;

}

$this->imgBuilt=true;

}

/**

*Addthegifstringfooterchar(old:GIFAddFooter)

*/

publicfunctiongifAddFooter()

{

$this->gif.=’;’;

}

/**

*Comparetwoblockandreturntheversion(old:GIFBlockCompare)

*

*@paramstring$globalBlock

*@paramstring$localBlock

*@paraminteger$length

*

*@returninteger

*/

publicfunctiongifBlockCompare($globalBlock,$localBlock,$length)

{

for($i=0;$i<$length;$i++){

if($globalBlock{3*$i+0}!=$localBlock{3*$i+0}||

$globalBlock{3*$i+1}!=$localBlock{3*$i+1}||

$globalBlock{3*$i+2}!=$localBlock{3*$i+2}){

return0;

}

}

return1;

}

/**

*EncodeanASCIIcharintoastringchar(old:GIFWord)

*

*$paraminteger$charASCIIchar

*

*@returnstring

*/

publicfunctionencodeAsciiToChar($char)

{

return(chr($char&0xFF).chr(($char>>8)&0xFF));

}

/**

*Resetandcleanthecurrentobject

*/

publicfunctionreset()

{

$this->frameSources;

$this->gif=’GIF89a’;//theGIFheader

$this->imgBuilt=false;

$this->loop=0;

$this->dis=2;

$this->colour=-1;

}

//Getter/Setter

//===================================================================================

/**

*GetthefinalGIFimagestring(old:GetAnimation)

*

*@returnstring

*/

publicfunctiongetGif()

{

return$this->gif;

}

}

END,本文到此结束,如果可以帮助到大家,还望关注本站哦!

站内搜索