贴段PHP画图的程序,给希望用PHP作图的朋友一点启发,帮助!_PHP
主要包括三个文件:
1、view.php是调用程序。
2、chart.php是用来生成图表的程序。
3、gbtoutf8.php是用来中文解码的(注:已解决中英文混合不能正常显示的问题)
1、view.php
include("gbtoutf8.php");
?>
/*此处数据可从数据库中取得*/
$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');
?>
2、chart.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
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
$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
}
else{
$ret.=substr($gb,0,1);
$gb=substr($gb,1,strlen($gb));
}
}
return $ret;
}
function u2utf8($c){
for($i=0;$i
if ($c $str.=$c;
}
else if ($c $str.=(0xC0 | $c>>6);
$str.=(0x80 | $c & 0x3F);
}
else if ($c $str.=(0xE0 | $c>>12);
$str.=(0x80 | $c>>6 & 0x3F);
$str.=(0x80 | $c & 0x3F);
}
else if ($c $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.="".$codetable[hexdec(bin2hex($this))-0x8080].";";
}
else{
$gb=substr($gb,1,strlen($gb));
$utf.=substr($gb,0,1);
}
}
return $utf;
}
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

To automate tasks and manage multiple systems, mission planning software is a valuable tool in your arsenal, especially as a system administrator. Windows Task Scheduler does the job perfectly, but lately many people have reported operator rejected request errors. This problem exists in all iterations of the operating system, and even though it has been widely reported and covered, there is no effective solution. Keep reading to find out what might actually work for other people! What is the request in Task Scheduler 0x800710e0 that was denied by the operator or administrator? Task Scheduler allows automating various tasks and applications without user input. You can use it to schedule and organize specific applications, configure automatic notifications, help deliver messages, and more. it

The operation of Windows is getting better and better with every version, with attractive features to improve the user experience. One feature users will want to explore on Windows 10 and 11 is the ability to sort photos by faces. This feature allows you to group photos of friends and family using facial recognition. Sounds fun, right? Read on to learn how to take advantage of this feature. Can I group photos by faces on Windows? Yes, you can use the Photos app to group pictures by faces on Windows 10 and 11. However, this feature is not available on the Photos app version. Additionally, you can link these photos to contacts using the People tab. Therefore, using this function you can

C++ is a widely used programming language that is very convenient and practical in writing countdown programs. Countdown program is a common application that can provide us with very precise time calculation and countdown functions. This article will introduce how to use C++ to write a simple countdown program. The key to implementing a countdown program is to use a timer to calculate the passage of time. In C++, we can use the functions in the time.h header file to implement the timer function. The following is the code for a simple countdown program

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

Do you frequently visit the same website at about the same time every day? This can lead to spending a lot of time with multiple browser tabs open and cluttering the browser while performing daily tasks. Well, how about opening it without having to launch the browser manually? It's very simple and doesn't require you to download any third-party apps, as shown below. How do I set up Task Scheduler to open a website? Press the key, type Task Scheduler in the search box, and then click Open. Windows On the right sidebar, click on the Create Basic Task option. In the Name field, enter the name of the website you want to open and click Next. Next, under Triggers, click Time Frequency and click Next. Select how long you want the event to repeat and click Next. Select enable

In iOS 17, Apple not only added several new messaging features, but also tweaked the design of the Messages app to give it a cleaner look. All iMessage apps and tools, such as the camera and photo options, can now be accessed by tapping the "+" button above the keyboard and to the left of the text input field. Clicking the "+" button brings up a menu column with a default order of options. Starting from the top, there's camera, photos, stickers, cash (if available), audio, and location. At the very bottom is a "More" button, which when tapped will reveal any other installed messaging apps (you can also swipe up to reveal this hidden list). How to reorganize your iMessage app You can do this below

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app
