function image_sincity($im) { $image = valeurs_image_trans($im, "sincity"); if (!$image) return(""); $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); $tol = 0.05 ; for ($x = 0; $x < $x_i; $x++) { for ($y=0; $y < $y_i; $y++) { $rgb = ImageColorAt($im, $x, $y); $a = ($rgb >> 24) & 0xFF; $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; if ($a < 127) { $hsv = image_rgb2hsv($r,$g,$b); $h = $hsv["h"]; $s = $hsv["s"]; $v = $hsv["v"]; if ($h < $tol OR $h > 1-$tol) { if ($h < $tol) { $dist = ($tol-$h); } else if ($h > 1-$tol) { $dist = ($h - (1-$tol)); } $s = $s * ($dist/$tol); if ($s > 1) $s = 1; $h = 0; } else { $s = 0; } $v = 2*($v - 0.6) + 0.6; if ($v > 1) $v=1; if ($v < 0) $v =0; $rgb = image_hsv2rgb($h,$s,$v); $r = $rgb["r"]; $g = $rgb["g"]; $b = $rgb["b"]; } $color = ImageColorAllocateAlpha( $im_, $r, $g, $b , $a ); 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"]; return ""; }