background image

9

    //imagerectangle($im,2,2,40,50,$red);   

10

    //填充矩形   

11

    //imagefilledrectangle($im,2,2,40,50,$red);   

12

    //弧线   

13

    //imagearc($im,100,100,50,50,180,270,$red);   

14

    //扇形   

15

    //imagefilledarc($im,100,100,80,50,180,270,$red,IMG_ARC_PIE);   

16

       

17

    //拷贝图片到画布   

18

    //1.加载源图片   

19

    //$srcImage=imagecreatefromgif("2.GIF");   

20

    //这里我们可以使用一个 getimagesize()   

21

    //$srcImageInfo=getimagesize("2.GIF");   

22

  

23

    //拷贝源图片到目标画布   

24

    //imagecopy($im,$srcImage,0,0,0,0,$srcImageInfo[0],$srcImageInfo[1]);   

25

  

26

    //写字   

27

    $str="hello,world,中文";   

28

    //imagestring($im,5,0,0,"hello,world,中文",$red);    

29

    //在字体库中去找中文   

30

    imagettftext($im,20,10,50,50,$red,"simhei.ttf",$str);   

31

    header("content-type: image/png");   

32

    imagepng($im);   

33

    imagedestory($im);   

34

?>  

综合案例

:(综合使用)

代码

:

Php 代码 

§

 

§

35

<?php   

36

  

37

       

38

    //分析思路(先画出扇形)   

39

  

40

  

41

    //1.画布   

42

    $im=imagecreatetruecolor(400,300);   

43

  

44

    //默认是黑色背景(一会告诉大家怎么修改)   

45

    $white=imagecolorallocate($im,255,255,255);   

46

    imagefill($im,0,0,$white);