Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1246 connectés 

  FORUM HardWare.fr
  Programmation

  génération d'image en php

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

génération d'image en php

n°29618
lamatrice
Posté le 07-05-2001 à 12:11:07  profilanswer
 

j'ai des problèmes pour générer des images sous php3
 
à chaque fois (j'ai l'icone d'image gif de l'exploreur à la  
place)

mood
Publicité
Posté le 07-05-2001 à 12:11:07  profilanswer
 

n°29639
kadreg
profil: Utilisateur
Posté le 07-05-2001 à 13:49:59  profilanswer
 

show me the code ...
 
Voici un exemple qui marche, qui fait un camembert à partir d'un tableau attribut/valeur, ca te donnera peut être une idée :
 

Code :
  1. function createCamembert ($filename, $values) {
  2.   $width = 400;
  3.   $height = 200;
  4.   $graph = imageCreate ($width, $height);
  5.   $white = ImageColorAllocate ($graph, 255,255,255);
  6.   $black = ImageColorAllocate ($graph, 0,0,0);
  7.   $fond = ImageColorAllocate ($graph, 245, 245, 245);
  8.   imagefill ($graph, 0, 0, $fond);
  9.   $total = 0;
  10.   $xLegendBegin = ($width - $height + 50);
  11.   $yLegend = 20;
  12.   $colors = array (ImageColorAllocate ($graph, 255,0,0),
  13.     ImageColorAllocate ($graph, 255,0,0),
  14.                    ImageColorAllocate ($graph, 0,255,0),
  15.     ImageColorAllocate ($graph, 0,0,255),
  16.     ImageColorAllocate ($graph, 0,255,255),
  17.     ImageColorAllocate ($graph, 255,0,255),
  18.     ImageColorAllocate ($graph, 255,255,0),
  19.     ImageColorAllocate ($graph, 255,128,64),
  20.     ImageColorAllocate ($graph, 128,64,255),
  21.     ImageColorAllocate ($graph, 64,255,128),
  22.     ImageColorAllocate ($graph, 64,128,255),
  23.     ImageColorAllocate ($graph, 255,64,128));
  24.   while (list ($name, $value) = each ($values)) {
  25.     $total += $value;
  26.   }
  27.   reset ($values);
  28.   $begin = 0;
  29.   $end = 0;
  30.   $radius = $height/2 - 10;
  31.   imageline ($graph, $height/2, $height/2, $height/2 + $radius, $height/2, $black);
  32.   imagearc ($graph, $height/2, $height/2, $radius * 2, $radius * 2, 0, 360, $black);
  33.   reset ($colors);
  34.   while (list ($name, $value) = each ($values)) {
  35.     $begin = $end;
  36.     $end = $begin + (($value * 360) / $total);
  37.     $xLineStart = $height / 2;
  38.     $yLineStart = $height / 2;
  39.     $xLineEnd = $height/2 + ($radius * cos (deg2rad ($end)));
  40.     $yLineEnd = $height/2 + ($radius * sin (deg2rad ($end)));
  41.     imageline ($graph, $xLineStart, $yLineStart,
  42.               $xLineEnd, $yLineEnd,
  43.               $black);
  44.     $color = next ($colors);
  45.     $xColorPoint = $height/2 + (($radius/2) * cos (deg2rad (($end + $begin)/ 2)));
  46.     $yColorPoint = $height/2 + (($radius/2) * sin (deg2rad (($end + $begin)/ 2)));
  47.     /* on ne fill que si end - begin > 5° */
  48.     if (abs($end - $begin) > 5){
  49.             imagefilltoborder ($graph, $xColorPoint, $yColorPoint, $black, $color);
  50.     }
  51.     /* la legende maintenant */
  52.     imagefilledrectangle ($graph, $xLegendBegin, $yLegend, $xLegendBegin + 10, $yLegend + 10, $color);
  53.     imagestring ($graph, 2, $xLegendBegin + 20, $yLegend, $name, $black);
  54.     $yLegend += 20;
  55.   }
  56.   unlink ($filename);
  57.   imageGif ($graph, $filename);
  58. }


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

  génération d'image en php

 

Sujets relatifs
Javascript : une image par jour !Comment imprimer une image en delphi
Je cherche un programme qui compresse une image en jpgattendre qu'une image soit finie d'etre chargee pour continuer ??
Insérer une image sur un bouton en VC++algo de retouche d'image en C
[HTML] formulaire et type="button"; changer le bouton en image ?[PHP ou HTML] Image et clique?
Frameset et image de fondgeneration d'image et php
Plus de sujets relatifs à : génération d'image en php


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR