肯定不是代码的问题,因为同样的代码简单的图就没问题,复杂了就不行(图大小没变),具体代码如下:
Header("Content-type: image/jpeg");
$im=imagecreate((int)$Width,(int)$Height);
ImageColorAllocate($im,255,255,255);
$line_color=ImageColorAllocate($im,200,200,200);
imagerectangle($im,1,1,$Width-1,$Height-1,$line_color);
$line_width=1;
$line_mode=1;
$line_color=ImageColorAllocate($im,200,200,200);
// 1、画线
map_jw_line($type,$jd1,$wd1,$jd2,$wd2,$org_jd,$jwd_jg,$bl,$line_width,$line_mode,$line_color,$im);//画经度、纬度线
map_bj_line($type,$org_jd,$bl,$line_width,$line_mode,$line_color,$im,"china_bj.dat");//画中国边界线
// map_bj_line($type,$org_jd,$bl,1,1,ImageColorAllocate($im,0,200,0),$im,"river_N.dat");
map_bj_line($type,$org_jd,$bl,1,1,ImageColorAllocate($im,0,200,0),$im,"Yellow_River.dat");//画黄河流域线
// 2、画县城名
for($i=0;$i<$num;$i++){
get_xy_01mm(1,114.0,$bl,$JD[$i],$WD[$i]);
get_xy_pels($bl);
$xx1=$XX;
$yy1=$YY;
$color=ImageColorAllocate($im,100,100,100);
imagearc($im,$xx1,$yy1,6,6,0,360,$color);
$xy=ImageTTFBBox(8,0,$font,gb2utf8($STATION1[$i]));
$xy0=($xy[2]-$xy[0])/2;
$xy1=-($xy[7]-$xy[1]);
$xx=$xx1-$xy0;
$yy=$yy1+$xy1;
ImageTTFText($im,8,0,$xx,$yy,$color,$font,gb2utf8($STATION1[$i]));//县名
if($lxf[$i]==0)continue;
}
// 3、图标
imagefilledrectangle($im,5,5,300,90,ImageColorAllocate($im,230,230,230));
$xs="黄河中下游流域降水量_".$PROVINCE;
$xy=ImageTTFBBox(14,0,$font,gb2utf8($xs));
$xy0=($xy[2]-$xy[0])/2;
ImageTTFText($im,14,0,150-$xy0,30,ImageColorAllocate($im,0,0,100),$font,gb2utf8($xs));
switch($type){
case 1: $xs0="麦卡托";break;
case 2: $xs0="北半球";break;
case 3: $xs0="兰勃托";break;
}
$xs="黄河中下游流域地图";
$xy=ImageTTFBBox(18,0,$font,gb2utf8($xs));
$xy0=($xy[2]-$xy[0]);
$x=(300-$xy0)/2;
$y=(int)$Height-35;
ImageTTFText($im,18,0,$x,$y,ImageColorAllocate($im,0,0,200),$font,gb2utf8($xs));
$xs1=sprintf("%d",1.0/($bl/10000000.0)+0.1);
$ii=(int)strlen($xs1);
$j=($ii-1)/3;
switch($j){
case 1:
$xs2=$xs1[$ii-1];
for($i=$ii;$i>1;$i--)$xs1[$i]=$xs1[$i-1];
$xs1[1]=',';
$xs1=$xs1.$xs2;
break;
case 2;
$xs2=$xs1[$ii-1];
for($i=$ii;$i>1;$i--)$xs1[$i]=$xs1[$i-1];
$xs1[1]=',';
$xs1=$xs1.$xs2;
$ii=(int)strlen($xs1);
$xs2=$xs1[$ii-1];
for($i=$ii;$i>5;$i--)$xs1[$i]=$xs1[$i-1];
$xs1[5]=',';
$xs1=$xs1.$xs2;
break;
}
$xs="投影:".$xs0." 比例: 1:".$xs1;
$xy=ImageTTFBBox(12,0,$font,gb2utf8($xs));
$xy0=($xy[2]-$xy[0]);
$x=(300-$xy0)/2;
$y=$y+25;
ImageTTFText($im,12,0,$x,$y,ImageColorAllocate($im,0,0,0),$font,gb2utf8($xs)); Imagejpeg($im);
ImageDestroy($im);问题是:
在 1、画线 部分,画线的多少是有 *.dat 坐标文件的大小决定的,当 *.dat 坐标文件简单时,2、画县城名及 3、画图标均正常,当 *.dat 坐标文件复杂时,2、画县城名及 3、画图标也能画出来,但是颜色就不是程序设置的颜色了,而且不定,请指教!
Header("Content-type: image/jpeg");
$im=imagecreate((int)$Width,(int)$Height);
ImageColorAllocate($im,255,255,255);
$line_color=ImageColorAllocate($im,200,200,200);
imagerectangle($im,1,1,$Width-1,$Height-1,$line_color);
$line_width=1;
$line_mode=1;
$line_color=ImageColorAllocate($im,200,200,200);
// 1、画线
map_jw_line($type,$jd1,$wd1,$jd2,$wd2,$org_jd,$jwd_jg,$bl,$line_width,$line_mode,$line_color,$im);//画经度、纬度线
map_bj_line($type,$org_jd,$bl,$line_width,$line_mode,$line_color,$im,"china_bj.dat");//画中国边界线
// map_bj_line($type,$org_jd,$bl,1,1,ImageColorAllocate($im,0,200,0),$im,"river_N.dat");
map_bj_line($type,$org_jd,$bl,1,1,ImageColorAllocate($im,0,200,0),$im,"Yellow_River.dat");//画黄河流域线
// 2、画县城名
for($i=0;$i<$num;$i++){
get_xy_01mm(1,114.0,$bl,$JD[$i],$WD[$i]);
get_xy_pels($bl);
$xx1=$XX;
$yy1=$YY;
$color=ImageColorAllocate($im,100,100,100);
imagearc($im,$xx1,$yy1,6,6,0,360,$color);
$xy=ImageTTFBBox(8,0,$font,gb2utf8($STATION1[$i]));
$xy0=($xy[2]-$xy[0])/2;
$xy1=-($xy[7]-$xy[1]);
$xx=$xx1-$xy0;
$yy=$yy1+$xy1;
ImageTTFText($im,8,0,$xx,$yy,$color,$font,gb2utf8($STATION1[$i]));//县名
if($lxf[$i]==0)continue;
}
// 3、图标
imagefilledrectangle($im,5,5,300,90,ImageColorAllocate($im,230,230,230));
$xs="黄河中下游流域降水量_".$PROVINCE;
$xy=ImageTTFBBox(14,0,$font,gb2utf8($xs));
$xy0=($xy[2]-$xy[0])/2;
ImageTTFText($im,14,0,150-$xy0,30,ImageColorAllocate($im,0,0,100),$font,gb2utf8($xs));
switch($type){
case 1: $xs0="麦卡托";break;
case 2: $xs0="北半球";break;
case 3: $xs0="兰勃托";break;
}
$xs="黄河中下游流域地图";
$xy=ImageTTFBBox(18,0,$font,gb2utf8($xs));
$xy0=($xy[2]-$xy[0]);
$x=(300-$xy0)/2;
$y=(int)$Height-35;
ImageTTFText($im,18,0,$x,$y,ImageColorAllocate($im,0,0,200),$font,gb2utf8($xs));
$xs1=sprintf("%d",1.0/($bl/10000000.0)+0.1);
$ii=(int)strlen($xs1);
$j=($ii-1)/3;
switch($j){
case 1:
$xs2=$xs1[$ii-1];
for($i=$ii;$i>1;$i--)$xs1[$i]=$xs1[$i-1];
$xs1[1]=',';
$xs1=$xs1.$xs2;
break;
case 2;
$xs2=$xs1[$ii-1];
for($i=$ii;$i>1;$i--)$xs1[$i]=$xs1[$i-1];
$xs1[1]=',';
$xs1=$xs1.$xs2;
$ii=(int)strlen($xs1);
$xs2=$xs1[$ii-1];
for($i=$ii;$i>5;$i--)$xs1[$i]=$xs1[$i-1];
$xs1[5]=',';
$xs1=$xs1.$xs2;
break;
}
$xs="投影:".$xs0." 比例: 1:".$xs1;
$xy=ImageTTFBBox(12,0,$font,gb2utf8($xs));
$xy0=($xy[2]-$xy[0]);
$x=(300-$xy0)/2;
$y=$y+25;
ImageTTFText($im,12,0,$x,$y,ImageColorAllocate($im,0,0,0),$font,gb2utf8($xs)); Imagejpeg($im);
ImageDestroy($im);问题是:
在 1、画线 部分,画线的多少是有 *.dat 坐标文件的大小决定的,当 *.dat 坐标文件简单时,2、画县城名及 3、画图标均正常,当 *.dat 坐标文件复杂时,2、画县城名及 3、画图标也能画出来,但是颜色就不是程序设置的颜色了,而且不定,请指教!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货