imagecolorallocate

imagecolorallocate imagecolorallocate imagecolorallocate()

imagecolorallocate
(PHP 3, PHP 4 )
imagecolorallocate -- 為一幅圖像分配顏色
說明
int imagecolorallocate ( resource image, int red, int green, int blue)
imagecolorallocate() 返回一個標識符,代表了由給定的 RGB 成分組成的顏色。image 參數是 imagecreate() 函式的返回值。red,green 和 blue 分別是所需要的顏色的紅,綠,藍成分。這些參數是 0 到 255 的整數或者十六進制的 0x00 到 0xFF。imagecolorallocate() 必須被調用以創建每一種用在 image 所代表的圖像中的顏色。
注: 第一個對 imagecolorallocate() 的調用填充背景色。
<?php
// 背景設為紅色
$background = imagecolorallocate($im, 255, 0, 0);
// 設定一些顏色
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// 十六進制方式
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);
?>
如果分配失敗則返回 -1。

相關詞條

相關搜尋

熱門詞條

聯絡我們