PHP imagecreate() 函数新建一个基于调色板的图像用法及示例 - PHP教程

由网友 大卫 发布 阅读 2

PHP imagecreate() 函数新建一个基于调色板的图像用法及示例 - PHP教程

PHP 图像处理

imagecolorallocate — 新建一个基于调色板的图像。

语法

imagecreate ( int $x_size , int $y_size ) : resource

imagecolorallocate() 返回一个图像标识符,代表了一幅大小为 x_size 和 y_size 的空白图像。

示例

<?php
header("Content-type: image/png");
$im = @imagecreate(100, 50)
    or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>

PHP 图像处理

PHP imagecolorset() 给指定调色板索引设定颜色 PHP imagecolorexact() 函数取得指定颜色的索引值