词条 | imagepng |
释义 | ImagePNG 建立 PNG 图型。 语法: int imagepng(int im, string [filename]); 返回值: 整数 函数种类: 图形处理 内容说明 本函数用来建立一张 PNG 格式图形。参数 im 为使用 ImageCreate() 所建立的图片代码。参数 filename 可省略,若无本参数 filename,则会将图片指接送到浏览器端,记得在送出图片之前要先送出使用 Content-type: image/png 的标头字符串 (header) 到浏览器端,以顺利传输图片。本函数在 PHP 3.0.13 版之后才支持。 使用本功能需要在编译 PHP 前先安装 GD library。在 1.6.2 版以前的 GD library 有支持 GIF 格式的功能,但因为 GIF 格式使用的 LZW 演算法牵涉到 Unisys 的专利权,因此在 GD library 1.6.2 版之后不支持 GIF 的格式。然而到了PHP5,GD库又支持创建GIF了。 以下是简单的例子: <?php Header("Content-type: image/gif"); $im = imagecreate(400,30); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); imageline($im, 1, 1, 350, 25, $black); imagearc($im, 200, 15, 20, 20, 35, 190, $white); imagestring($im, 5, 4, 10, "Graph TEST!!", $white); ImageGif($im); ImageDestroy($im); ?> |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。