function image_contour_alpha($im, $coul='000000', $trait=1) { $image = valeurs_image_trans($im, "contour-$coul-$trait", "png"); if (!$image) return(""); include_ecrire("filtres"); $couleurs = couleur_hex_to_dec($coul); $dr= $couleurs["red"]; $dv= $couleurs["green"]; $db= $couleurs["blue"]; $x_i = $image["largeur"]; $y_i = $image["hauteur"]; $im = $image["fichier"]; $dest = $image["fichier_dest"]; $creer = $image["creer"]; if ($creer) { $im = $image["fonction_imagecreatefrom"]($im); $im_ = imagecreatetruecolor($x_i, $y_i); @imagealphablending($im_, false); @imagesavealpha($im_,true); $color_t = ImageColorAllocateAlpha( $im_, 255, 255, 255 , 127 ); imagefill ($im_, 0, 0, $color_t); for ($x = 0; $x < $x_i; $x++) { for ($y=0; $y < $y_i; $y++) { $rgb = ImageColorAt($im, $x, $y); $a = ($rgb >> 24) & 0xFF; $dif = false; $m = 0; $t = 0; for ($ix = -1*$trait/2; $ix <= $trait/2; $ix++) { for ($iy = -1*$trait/2; $iy <= $trait/2; $iy++) { $x2 = $x + $ix; $y2 = $y + $iy; if ($x2 >=0 AND $y2 >= 0 AND $x2 < $x_i AND $y2 < $y_i) { $t++; $rgb2 = ImageColorAt($im, $x2, $y2); $a2 = ($rgb2 >> 24) & 0xFF; $r2 = ($rgb2 >> 16) & 0xFF; $g2 = ($rgb2 >> 8) & 0xFF; $b2 = $rgb2 & 0xFF; if ($a != $a2) { $dx = min(abs($ix),abs($iy)); $dy = max(abs($ix),abs($iy)); if ($mem[$dx][$dy]) $d = $mem[$dx][$dy]; else { $mem[$dx][$dy] = sqrt(($dx)*($dx)+($dy)*($dy)); $d = $mem[$dx][$dy]; } if ($d>0) { $m = $m + (abs($a2-$a) / $d); } else { $m = $m + 127; } } } } } $m = 127 - (($m / $t) * $trait); $m = min(max($m, 0), 127); $color = ImageColorAllocateAlpha( $im_, $dr, $dv, $db , round($m) ); imagesetpixel ($im_, $x, $y, $color); } } $image["fonction_image"]($im_, "$dest"); } $class = $image["class"]; if (strlen($class) > 1) $tags=" class='$class'"; $tags = "$tags alt='".$image["alt"]."'"; $style = $image["style"]; if (strlen($style) > 1) $tags="$tags style='$style'"; return ""; }