• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    PHP畫圖的程序

    發布: 2007-7-14 19:53 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 63次 | 進入軟件測試論壇討論

    領測軟件測試網 主要包括三個文件:
    1、view.php是調用程序。
    2、chart.php是用來生成圖表的程序。
    3、gbtoutf8.php是用來中文解碼的(注:已解決中英文混合不能正常顯示的問題)

    1、view.php
    <?
    include("gbtoutf8.php");
    ?>
    <html>
    <head>
    <title>  </title>
    <meta name="Author" content="XIANG Li">
    </head>
    <?
    /*此處數據可從數據庫中取得*/
    $aStr = "IT,PC,Phone,Sever,Passport,Software";
    $aSoft = "Win2000,Win98,Office,Foxmail,Outlook";
    $aHard = gb2utf8("地板,窗戶,玻璃,桌子,燈管,植被");
    $title1 = gb2utf8('2002年IT維護report');
    $title2 = gb2utf8('2002年軟件維護report');
    $title3 = gb2utf8('2002年固定資產report');
    ?>
    <body>
    <div align="center">
    <table>
    <tr>
        <td><input type="image" src="./chart.php?aStr=<?=$aStr?>&title=<?=$title1?>"></td>
    </tr>
    <tr><td> </td></tr>
    <tr>
        <td><input type="image" src="./chart.php?aStr=<?=$aSoft?>&title=<?=$title2?>"></td>
    </tr>
    <tr><td> </td></tr>
    <tr>
        <td><input type="image" src="./chart.php?aStr=<?=$aHard?>&title=<?=$title3?>"></td>
    </tr>
    </table></div>
    </body>
    </html>

    2、chart.php
    <?php
    /*
    *  功能:生成統計圖表
    *  程序員:wlxz
    * 日期:2002-00-00
    */

    Header("Content-type: image/png");
      $im = ImageCreate (350, 280);
      $col_oth = ImageColorAllocate($im, 0,0,0);
      $col_orn = ImageColorAllocate($im, 255,192,0);
      $col_yel = ImageColorAllocate($im, 255,255,0);
      $col_red = ImageColorAllocate($im, 255,0,0);
      $col_grn = ImageColorAllocate($im, 0,255,0);
      $col_blu = ImageColorAllocate($im, 0,0,255);
      $col_wit = ImageColorAllocate($im, 255,255,255);
      $col_array = array($col_oth, $col_orn, $col_yel, $col_red, $col_grn, $col_blu);

    $dot1 = 28;
    $dot2 = 20;
    $font="c:/winnt/fonts/simhei.ttf";
    $aStr = explode(",", trim($_GET['aStr']));
    $title = trim($_GET['title']);

    ImageTTFText($im,18,0,100,50,$col_wit,$font,$title);//寫標題

      for($i=1;$i<count($col_array);$i++){
      ImageFilledRectangle($im,50*$i-$dot2,$dot1*$i,50*$i,200,$col_array[$i]);
      ImageRectangle($im,50*$i-$dot2,$dot1*$i,50*$i,200,$col_wit);
      ImageRectangle($im,50*$i-$dot2-1,$dot1*$i-1,50*$i+1,200,$col_wit);
      ImageTTFText($im,14,270,50*$i-15,205,$col_wit,$font,$aStr[$i-1]);
      
    // ImageLine($im,50*$i-$dot2,$dot1*$i,50*$i-$dot2,200,$col_wit);
      ImageLine($im,50*$i-$dot2,$dot1*$i,50*$i,$dot1*$i,$col_wit);
      }
      ImageRectangle($im,10,10,300,200,$col_wit);
      ImageRectangle($im,11,11,301,201,$col_wit);

    //右邊百分比
      for($i=1;$i<count($col_array);$i++){
        ImageLine($im,300,$i*33,306,$i*33,$col_wit);
        $str = (100-$i*5)."%";
        ImageTTFText($im,14,0,315,$i*33+2,$col_wit,$font,$str);
      }

      ImagePNG($im);
      ImageDestroy($im);
    ?>

    3.gbtoutf8.php
    <?
    /*
    *  功能:把GB2312編碼轉換成UTF-8的編碼
    *  程序員:wlxz
    * 日期:2002-00-00
    */

    function gb2utf8($gb){
        if(!trim($gb))
            return $gb;

        $filename="gb2312.txt";
        $tmp=file($filename);
        $codetable=array();
        
        while(list($key,$value)=each($tmp))
            $codetable[hexdec(substr($value,0,6))]=substr($value,7,6);
        
        $ret="";
        $utf8="";
        
        while($gb){
            if (ord(substr($gb,0,1))>127)
                {
                $this=substr($gb,0,2);
                $gb=substr($gb,2,strlen($gb));
                $utf8=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));

                for($i=0;$i<strlen($utf8);$i+=3)
                    $ret.=chr(substr($utf8,$i,3));
                }
                else{
                    $ret.=substr($gb,0,1);
                    $gb=substr($gb,1,strlen($gb));
                    }
        }
        
        return $ret;
    }

    function u2utf8($c){
        for($i=0;$i<count($c);$i++)
            $str="";

        if ($c < 0x80){
            $str.=$c;
        }
        else if ($c < 0x800){
            $str.=(0xC0 | $c>>6);
            $str.=(0x80 | $c & 0x3F);
        }
        else if ($c < 0x10000){
            $str.=(0xE0 | $c>>12);
            $str.=(0x80 | $c>>6 & 0x3F);
            $str.=(0x80 | $c & 0x3F);
        }
        else if ($c < 0x200000){
            $str.=(0xF0 | $c>>18);
            $str.=(0x80 | $c>>12 & 0x3F);
            $str.=(0x80 | $c>>6 & 0x3F);
            $str.=(0x80 | $c & 0x3F);
        }
        
        return $str;
    }


    function gb2unicode($gb){
        if(!trim($gb))
            return $gb;
        
        $filename="gb2312.txt";
        $tmp=file($filename);
        $codetable=array();

        while(list($key,$value)=each($tmp))
            $codetable[hexdec(substr($value,0,6))]=substr($value,9,4);
        $utf="";
        while($gb){
            if (ord(substr($gb,0,1))>127){
                $this=substr($gb,0,2);
                $gb=substr($gb,2,strlen($gb));
                $utf.="&#x".$codetable[hexdec(bin2hex($this))-0x8080].";";
                }
                else{
                    $gb=substr($gb,1,strlen($gb));
                    $utf.=substr($gb,0,1);
                    }
        }
        return $utf;
    }
    ?>

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>