Ver Mensaje Individual
  #10 (permalink)  
Antiguo 25/11/2010, 13:28
cmarrero
(Desactivado)
 
Fecha de Ingreso: enero-2008
Ubicación: Mendoza
Mensajes: 458
Antigüedad: 16 años, 3 meses
Puntos: 2
Respuesta: Consulta al Foro

Estoy haciendo algunas pruebas con la libreria GD de php, tenes idea por que la imagen aparece de mala calidad ???..

http://smartup.com.ar/gd.php
Código PHP:
Ver original
  1. <?php
  2. function DrawTextArc($str, $aStart, $aEnd, $iRadius, $bCCW)
  3. {
  4.         $nFont = 5;
  5.         // create image to store each character
  6.         $xFont = imagefontwidth($nFont);
  7.         $yFont = imagefontheight($nFont);
  8.         $imgChar = imagecreatetruecolor($xFont, $yFont);
  9.         // create overall image
  10.         $iCentre = $iRadius + max($xFont, $yFont);
  11.         $img = imagecreatetruecolor(2 * $iCentre, 2 * $iCentre);
  12.         // sort out colours
  13.         $colBG = imagecolorallocate($img, 255, 255, 255);
  14.         $colBGchar = imagecolorallocate($imgChar, 255, 255, 255);
  15.         $colFGchar = imagecolorallocate($imgChar, 0, 0, 0);
  16.         imagefilledrectangle($img, 0, 0, 2 * $iCentre, 2 * $iCentre, $colBG);
  17.          
  18.         // arrange angles depending on direction of rotation
  19.         if ($bCCW){
  20.                 while ($aEnd < $aStart){
  21.                     $aEnd += 360;
  22.                 }
  23.         }else{
  24.                 while ($aEnd > $aStart){
  25.                         $aEnd -= 360;
  26.                 }
  27.         }
  28.         $len = strlen($str);
  29.         // draw each character individually
  30.         for ($i = 0; $i < $len; $i++)
  31.         {
  32.                 // calculate angle along arc
  33.                 $a = ($aStart * ($len - 1 - $i) + $aEnd * $i) / ($len - 1);
  34.          
  35.                 // draw individual character
  36.                 imagefilledrectangle($imgChar, 0, 0, $xFont, $yFont, $colBGchar);
  37.                 imagestring($imgChar, $nFont, 0, 0, $str[$i], $colFGchar);
  38.          
  39.                 // rotate character
  40.                 $imgTemp = imagerotate($imgChar, (int)$a + 90 * ($bCCW ? 1 : -1), $colBGchar);
  41.                 $xTemp = imagesx($imgTemp);
  42.                 $yTemp = imagesy($imgTemp);
  43.          
  44.                 // copy to main image
  45.                 imagecopy($img, $imgTemp,
  46.                                         $iCentre + $iRadius * cos(deg2rad($a)) - ($xTemp / 2),
  47.                                         $iCentre - $iRadius * sin(deg2rad($a)) - ($yTemp / 2),
  48.                                         0, 0, $xTemp, $yTemp);
  49.         }
  50.          
  51.         return $img;
  52. }
  53. $img = DrawTextArc("Happy Birthday Felipe", 180, 360, 80, false);
  54. // output the image
  55. header("Content-type: image/jpeg");
  56. imagejpeg($img);
  57. ?>