Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/06/2007, 21:33
Avatar de minkweb
minkweb
 
Fecha de Ingreso: septiembre-2005
Mensajes: 443
Antigüedad: 18 años, 8 meses
Puntos: 14
Re: No funciona creador de imagen

ok chikuelo revise tu codigo.. usalo asi


Código PHP:
<?
 $font 
="./inc/luxisb.ttf";

 
session_start();

$w 80;
$h 25;
$fsize 11;
$total 5//Cantidad de numeros

$img imagecreate($w,$h);
for (
$i 0$i $total$i++) {
$str .= rand(0,9);
}
$_SESSION["codigo"] = $str;
$bgcolor get_color(120,255);
$txtcolor get_color(0,120);


 
preg_match_all("/.{2}/","FFFFFF",$m);

 
$clr['r']=hexdec($m[0][0]);
 
$clr['g']=hexdec($m[0][1]);
 
$clr['b']=hexdec($m[0][2]);

$rou rand(1050);;
$a rand(-77);

$str_p imageTTFBbox($fsize,$a,$font,$str);
$p_h $str_p[5]-$str_p[1];
$p_w $str_p[4]-$str_p[0];

imagettftext($img$fsize$a,ceil(($w-$p_w)/2),ceil(($h-$p_h)/2),$txtcolor,$font,$str);
get_arcs($rou,$clr); //arcs


header("Content-type: image/png");
imagePng($img);
imageDestroy($img);

function 
get_arcs($r =10,$clr=""){

 global 
$w,$h,$img;

   
$circs ceil($w/$r);
   for (
$i=0;$i<=$circs;$i++){
     
$arcclor get_color(120,255,$clr);
     
$x $i*$r;
     
imagearc($img,-10+$x , -10+$x$h*2+$x$h*2+$x0360$arcclor);

   }



}
function 
get_color($mincolor=0,$maxcolor=255,$clr=""){

  global 
$img;

if (
$clr['r'] and $clr['g'] and $clr['b']){

 
$rescolor imagecolorallocate($img$clr['r'], $clr['g'], $clr['b']);
}else{
 
$r rand($mincolor$maxcolor);
 
$g rand($mincolor$maxcolor);
 
$b rand($mincolor$maxcolor);
 
$rescolor imagecolorallocate($img$r$g$b);
}


 return 
$rescolor;
}

?>
Llamas la imagen asi <img src="imagen.php"> en tal caso q el archivo se llama imagen.php

$_SESSION["codigo"] = $str ---> este seria el valor q se metera en la sesion para q puedas validar

espero q t funcione saludos