1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
function labelv2($main_im,$string,$font,$textcolor,$bgcolor){
$pix_width=imagefontwidth($font)*strlen($string);
$pix_height=imagefontheight($font);
$pad=2;
$im = @imagecreate ($pix_width+$pad*2+4,$pix_height+$pad*2) or die ("Cannot Initialize new GD image stream");
$color_tran_bg = imagecolorsforindex($main_im, $bgcolor);
$bgcolor=imagecolorallocate($im,$color_tran_bg[red],$color_tran_bg[green],$color_tran_bg[blue]);
$color_tran_fg = imagecolorsforindex($main_im, $textcolor);
$textcolor=imagecolorallocate($im,$color_tran_fg[red],$color_tran_fg[green],$color_tran_fg[blue]);
imagefilledrectangle($im, 0, 0, $pix_width+$pad*2+4, $pix_height+$pad*2-1, $textcolor);
imagefilledrectangle($im, 1, 1, $pix_width+$pad*2+2, $pix_height+$pad*2-2, $bgcolor);
imagestring($im, $font, 0+$pad+2, 0+$pad/2, $string, $textcolor);
return ($im);
} |
Partager