function int2rgb($rgb){
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
return array($r,$g,$b);
}
function aimg($a){//white background/1-black
$h=count($a);
$w=count($a[0]);
$d=imagecreatetruecolor($w,$h);
$white = ImageColorAllocate ($d, 255, 255, 255);
ImageFill($d, 0, 0, $white);
foreach($a as $b11=>$b12){
foreach ($b12 as $b21=>$b22){
if($b22){
imagesetpixel($d,$b21+1,$b11+1,0);
}
}
}
return $d;
}
function afile($n,$f){
if(end(explode('.',$f))=='gif') imagegif($n,$f);
else if(end(explode('.',$f))=='png') imagepng($n,$f);
else imagejpeg($n,$f);
}
function imgzoom($a,$k){//a-resource:imagecreatefromstring(file_get_contents('xxx.jpg'));
$w=imagesx($a);
$h=imagesy($a);
$ww=$k*$iiw;
$hh=$k*$iih;
$d=imagecreatetruecolor($ww,$hh);
imagecopyresized($d,$a,0,0,0,0,$ww,$hh,$w,$h);
return $d;
}
function imgturn($a,$k){
$w=imagesx($a);
$h=imagesy($a);
$d=imagecreatetruecolor($w,$h);
imageCopyResized($d,$a,0,0,0,0,$w,$h,$w,$h);
$white=imagecolorallocate($d,255,255,255);
$d=imagerotate($d,$k,$white);
return $d;
}