Bonjour,
J'utilise la fonction imagefilledellipse dans une focntion php pour creer une image.
Mais le resultat est tres crado !
Quelqu'un sait comment faire un anti-aliasing ou truc pour rendre le resultat plus beau ?
Merci.
Bonjour,
J'utilise la fonction imagefilledellipse dans une focntion php pour creer une image.
Mais le resultat est tres crado !
Quelqu'un sait comment faire un anti-aliasing ou truc pour rendre le resultat plus beau ?
Merci.
En regardant un peu la doc, je trouve imageantialias
As toi de voir si cela te convient ou pas
M'enfin chercher dans la doc ne prends 1h et évite de poulluer le forum.
Pierre
j'ai chercher dans la doc et antialias n'a eu aucun effet c'est pour ca que j'ai poster dans le forum.
Alors je ne vois pas,
Mais tu aurais du indiqué ce que tu avais essayé, cela aurait évité mon post un peu 'méchant'.
@FCYPBA : Merci de laisser la modération aux modérateurs
@ouquoi : En quel format envoies-tu ton image ? Perso, j'ai eu quelques soucis de qualité d'image avec le GIF, tandis que le JPEG passe bien.
Mes articles - Zend Certified Engineer (PHP + Zend Framework)
Ressources PHP - Ressources Zend Framework - Cours et tutoriels pour apprendre PHP - Forum PHP
si tu pouvais nous montrer le resultat pour voir ce que tu trouves "crado" ^^
Pour moi le jpeg et le png passent plutot bien.
- FAQ Jeux - FAQ SDL - FAQ DirectX - FAQ OpenGL - FAQ 3D
- Tutoriels Jeux - Outils
- Mes tutos : http://loka.developpez.com - tuto sdl
Nah.
Effectivement l'antialiasing a pas du passer, tu devrais poster ton code et préciser quelle version de GD tu utilises ?
Ah, je vois mieux à quoi tu faisais référence ^^
Une solution pourrait consister en la création d'une image plus grande et de la réduire. Je n'ai pas testé mais il n'y a pas de raison...
[Edit] Tu as nien essayé avec imageantialias() ?
Mes articles - Zend Certified Engineer (PHP + Zend Framework)
Ressources PHP - Ressources Zend Framework - Cours et tutoriels pour apprendre PHP - Forum PHP
oui en effet c'est pas beau
je pense que la solution de kirkis marche, si l'antiallias ne marche pas tu peux toujours te pencher dessus![]()
- FAQ Jeux - FAQ SDL - FAQ DirectX - FAQ OpenGL - FAQ 3D
- Tutoriels Jeux - Outils
- Mes tutos : http://loka.developpez.com - tuto sdl
Pas de meilleur resultat avec la fonction antialias voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 function print_png_with_color($icone,$color,$bgcolor) { $pixel_cadre = 40; $pixel_cercle = 20; $filename = ".\\images\\".$icone; $img = ImageCreateFromPng($filename); if($img == "") { echo "ERROR"; return; } //Dimensions de l'image $imgWidth = imagesx($img) + $pixel_cadre; $imgHeight = imagesy($img)+ $pixel_cadre; $imgWidthCercle = imagesx($img) + $pixel_cercle; $imgHeightCercle = imagesy($img)+ $pixel_cercle; //Crée le thumb (image réduite) $imgComplete = ImageCreateTruecolor($imgWidth, $imgHeight); imageantialias( $imgComplete, True ); $background = fromhex($bgcolor,$imgComplete); imagefill( $imgComplete, 0, 0,$background); $background = fromhex($bgcolor,$imgComplete); // couleur de remplissage de l'ellipse $col_ellipse = fromhex($color,$imgComplete); imagefilledellipse($imgComplete, $imgWidth/2, $imgHeight/2, $imgWidthCercle, $imgHeightCercle, $col_ellipse); $posx = $pixel_cadre / 2; ImageCopy($imgComplete,$img,$posx,$posx,0,0,$imgWidth-$pixel_cadre,$imgWidth-$pixel_cadre); // on affiche l'image header("Content-type: image/png"); imagepng($imgComplete); }
tu fais l'antialias avant la creation de l'elipse, je pense qu'il faudrait le faire après![]()
- FAQ Jeux - FAQ SDL - FAQ DirectX - FAQ OpenGL - FAQ 3D
- Tutoriels Jeux - Outils
- Mes tutos : http://loka.developpez.com - tuto sdl
C'est ptet une connerie mais à mon avis l'antialiasing doit être placé plus loin dans ton code, je dirais meme juste avant de la renvoyer, quand tous les traitements ont été fait. ( juste avant ton image copy )
Essai et dis nous![]()
Pour vérifier l'emplacement auquel il faut placer imageantialias, je découvre plein de chose sur cette fonction ( directive serait un terme plus approprié je pense)
Pour ma part, je pense que l'endroit ou il faut la placer n'a pas d'importance
par contre dans les notes de la fonctions, je découvre cette sympathique fonction utilisateur
A tester
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 The following function draws an AntiAliased (unfilled) Ellipse. It is used just liked the nomral ImageEllipse function. The optional parameter sets the number of segments... function ImageEllipseAA( &$img, $x, $y, $w, $h,$color,$segments=70) { $w=$w/2; $h=$h/2; $jump=2*M_PI/$segments; $oldx=$x+sin(-$jump)*$w; $oldy=$y+cos(-$jump)*$h; for($i=0;$i<2*(M_PI);$i+=$jump) { $newx=$x+sin($i)*$w; $newy=$y+cos($i)*$h; ImageLine($img,$newx,$newy,$oldx,$oldy,$color); $oldx=$newx; $oldy=$newy; } }
Pierre
Bon la reponse tarde un peu, et c vrai que GD trace des cercles vraiment pas beau. Mais pour ceux qui passerai dans le coin, voici une fonction qui repond a ce forum.
function imageSmoothCircle( &$img, $cx, $cy, $cr, $color ) {
$ir = $cr;
$ix = 0;
$iy = $ir;
$ig = 2 * $ir - 3;
$idgr = -6;
$idgd = 4 * $ir - 10;
$fill = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], 0 );
imageLine( $img, $cx + $cr - 1, $cy, $cx, $cy, $fill );
imageLine( $img, $cx - $cr + 1, $cy, $cx - 1, $cy, $fill );
imageLine( $img, $cx, $cy + $cr - 1, $cx, $cy + 1, $fill );
imageLine( $img, $cx, $cy - $cr + 1, $cx, $cy - 1, $fill );
$draw = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], 42 );
imageSetPixel( $img, $cx + $cr, $cy, $draw );
imageSetPixel( $img, $cx - $cr, $cy, $draw );
imageSetPixel( $img, $cx, $cy + $cr, $draw );
imageSetPixel( $img, $cx, $cy - $cr, $draw );
while ( $ix <= $iy - 2 ) {
if ( $ig < 0 ) {
$ig += $idgd;
$idgd -= 8;
$iy--;
} else {
$ig += $idgr;
$idgd -= 4;
}
$idgr -= 4;
$ix++;
imageLine( $img, $cx + $ix, $cy + $iy - 1, $cx + $ix, $cy + $ix, $fill );
imageLine( $img, $cx + $ix, $cy - $iy + 1, $cx + $ix, $cy - $ix, $fill );
imageLine( $img, $cx - $ix, $cy + $iy - 1, $cx - $ix, $cy + $ix, $fill );
imageLine( $img, $cx - $ix, $cy - $iy + 1, $cx - $ix, $cy - $ix, $fill );
imageLine( $img, $cx + $iy - 1, $cy + $ix, $cx + $ix, $cy + $ix, $fill );
imageLine( $img, $cx + $iy - 1, $cy - $ix, $cx + $ix, $cy - $ix, $fill );
imageLine( $img, $cx - $iy + 1, $cy + $ix, $cx - $ix, $cy + $ix, $fill );
imageLine( $img, $cx - $iy + 1, $cy - $ix, $cx - $ix, $cy - $ix, $fill );
$filled = 0;
for ( $xx = $ix - 0.45; $xx < $ix + 0.5; $xx += 0.2 ) {
for ( $yy = $iy - 0.45; $yy < $iy + 0.5; $yy += 0.2 ) {
if ( sqrt( pow( $xx, 2 ) + pow( $yy, 2 ) ) < $cr ) $filled += 4;
}
}
$draw = imageColorExactAlpha( $img, $color[ 'R' ], $color[ 'G' ], $color[ 'B' ], ( 100 - $filled ) );
imageSetPixel( $img, $cx + $ix, $cy + $iy, $draw );
imageSetPixel( $img, $cx + $ix, $cy - $iy, $draw );
imageSetPixel( $img, $cx - $ix, $cy + $iy, $draw );
imageSetPixel( $img, $cx - $ix, $cy - $iy, $draw );
imageSetPixel( $img, $cx + $iy, $cy + $ix, $draw );
imageSetPixel( $img, $cx + $iy, $cy - $ix, $draw );
imageSetPixel( $img, $cx - $iy, $cy + $ix, $draw );
imageSetPixel( $img, $cx - $iy, $cy - $ix, $draw );
}
}
$img = imageCreateTrueColor( 320, 240 );
imageSmoothCircle( $img, 160, 120, 100, array( 'R' => 0xCC, 'G' => 0x33, 'B' => 0x00 ) );
imageSmoothCircle( $img, 170, 110, 75, array( 'R' => 0xDD, 'G' => 0x66, 'B' => 0x00 ) );
imageSmoothCircle( $img, 180, 100, 50, array( 'R' => 0xEE, 'G' => 0x99, 'B' => 0x00 ) );
imageSmoothCircle( $img, 190, 90, 25, array( 'R' => 0xFF, 'G' => 0xCC, 'B' => 0x00 ) );
header( 'Content-Type: image/png' );
imagePNG( $img );
Bon alors changer la position de l'antialias ne change rien.
Quand a la fonction ImageEllipseAA ce n'est pas plus fin voir pire meme avec 200000 segment ...
Je pense que la solution qu'il te reste pour le moment c'est d'essayer de faire une image plus grande et d'en faire un thumb avec imagecopyresampled()
- FAQ Jeux - FAQ SDL - FAQ DirectX - FAQ OpenGL - FAQ 3D
- Tutoriels Jeux - Outils
- Mes tutos : http://loka.developpez.com - tuto sdl
Partager