Tema: FAQ's de PHP
Ver Mensaje Individual
  #132 (permalink)  
Antiguo 18/02/2005, 16:47
Anarko
 
Fecha de Ingreso: febrero-2004
Mensajes: 1.987
Antigüedad: 20 años, 2 meses
Puntos: 22
El abc de crear una imagen Espectacular.

No se tu, pero cuando me pille esto en el manual de PHP, (buscando por imagecolorallocatealpha), quede anonadado, correlo, (y estudialo), solo necesitas tener la libreria GD, la imagen se crea TODA con estas lineas, nada de includes ni otras librerias:

Código PHP:
<?php
$size 
300;
$image=imagecreatetruecolor($size$size);

// something to get a white background with black border
$back imagecolorallocate($image255255255);
$border imagecolorallocate($image000);
imagefilledrectangle($image00$size 1$size 1$back);
imagerectangle($image00$size 1$size 1$border);

$yellow_x 100;
$yellow_y 75;
$red_x    120;
$red_y    165
$blue_x   187;
$blue_y   125
$radius   150;

// allocate colors with alpha values
$yellow imagecolorallocatealpha($image255255075);
$red    imagecolorallocatealpha($image2550075);
$blue   imagecolorallocatealpha($image0025575);

// drawing 3 overlapped circle
imagefilledellipse($image$yellow_x$yellow_y$radius$radius$yellow);
imagefilledellipse($image$red_x$red_y$radius$radius$red);   
imagefilledellipse($image$blue_x$blue_y$radius$radius$blue);

// don't forget to output a correct header!
header('Content-type: image/png');

// and finally, output the result
imagepng($image);
imagedestroy($image);
?>
Hermoso, verdad?.

Salu2!.