Date
May. 19th, 2024
 
2024年 4月 12日

Post: PHP Primer 023 : 图像处理(一)

PHP Primer 023 : 图像处理(一)

Published 12:02 Feb 02, 2012.

Created by @ezra. Categorized in #Programming, and tagged as #PHP.

Source format: Markdown

Table of Content

这一篇主要介绍 PHP 中的 Grahpic Device 库的使用。

CD 已经在 PHP 中集成,我们要做的很简单:

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

新建画布

接下来,要画图首先当然要有画布:

$img = imagecreatetruecolor(100, 100);

颜色设定

为画笔设定颜色吧:

$red = imagecolorallocate($img, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($img, 0x00, 0x00, 0x00);

填充画布

imagefill($img, 0, 0, $red);

线条绘制

imageline($img, 0, 0, 100, 100, $black);

输出图像

输出到浏览器中:

imagepng($img);

释放内存

imagedestroy($img);
?>
Pinned Message
HOTODOGO
I'm looking for a SOFTWARE PROJECT DIRECTOR / SOFTWARE R&D DIRECTOR position in a fresh and dynamic company. I would like to gain the right experience and extend my skills while working in great teams and big projects.
Feel free to contact me.
For more information, please view online résumé or download PDF
本人正在寻求任职 软件项目经理 / 软件技术经理 岗位的机会, 希望加⼊某个新鲜⽽充满活⼒的公司。
如有意向请随时 与我联系
更多信息请 查阅在线简历下载 PDF