不爱贞子爱爽子
バキューン
<?php
/* 
//新建图像
//雪花
 @header("Content-Type:image/png");
$w = 500;
$h = 500;
//create
$img = imagecreate($w,$h);
//设置底色
imagecolorallocate($img,120,200,150);    
$snowflake_size = 5;  //1dao5
//利用循环生成雪花    imagechar() 输出*号
for ($i=1; $i<=400; $i++){
    imagechar($img,$snowflake_size,mt_rand(0,$w),mt_rand(0,$h),"*",imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255)));
 
}
imagepng($img);
$imagedestroy($img);
//resource imagecreatetruecolor($w,$h);
 */
 
 @header("Content-Type:image/png; charset=utf-8");
$imgWidth = 600;  
$imgHeight = 400;  
$img = imagecreatetruecolor($imgWidth, $imgHeight);  
imagefill($img, 0, 0, imagecolorallocate($img, 240, 240, 240));//设置底色  
$snowflake_size = 30;  
$font_file = "c:\\WINDOWS\\Fonts\\simhei.ttf";   
//生成大雪花 其实就是调用imagettftext()输出*号  
for ($i=1; $i<=400; $i++)   
{  
    $font_color = imagecolorallocate($img, mt_rand(100,200), mt_rand(100,200), mt_rand(100,200));  
    imagettftext($img, $snowflake_size, mt_rand(0, 180), mt_rand(0, $imgWidth),mt_rand(0, $imgHeight), $font_color, $font_file, "*");   
}  
//水印文字  
$black_color = imagecolorallocate($img, 0, 0, 0);
$text = iconv("GB2312", "UTF-8", "雪花儿  by MoreWindows"); //将中文字转换为UTF8   
imagettftext($img, 12, 0, $imgWidth - 200 , $imgHeight - 20, $black_color, $font_file, $text);  
imagepng($img);  
imagedestroy($img);  
 
?>
posted on 2018-01-02 11:56  不爱贞子爱爽子  阅读(400)  评论(0编辑  收藏  举报

! !