imagexbm

(PHP 5, PHP 7, PHP 8)

imagexbm將 XBM 圖像輸出到瀏覽器或文件

說明

imagexbm(resource $image, string $filename, int $foreground = ?): bool

XBM 圖像 image 輸出到瀏覽器或文件

參數(shù)

image

由圖象創(chuàng)建函數(shù)(例如imagecreatetruecolor())返回的 GdImage 對象。

filename

文件保存的路徑或者已打開的流資源(此方法返回后自動關(guān)閉該流資源),如果未設(shè)置或為 null,將會直接輸出原始圖象流。

foreground

你可以從 imagecolorallocate() 分配一個顏色,并設(shè)置為該前景色參數(shù)。 默認顏色是黑色。

返回值

成功時返回 true, 或者在失敗時返回 false

范例

示例 #1 保存一個 XBM 文件

<?php
// 創(chuàng)建空白圖像并添加文字
$im imagecreatetruecolor(12020);
$text_color imagecolorallocate($im2331491);
imagestring($im155,  'A Simple Text String'$text_color);

// 保存圖像
imagexbm($im'simpletext.xbm');

// 釋放內(nèi)存
imagedestroy($im);
?>

示例 #2 以不同前景色保存一個 XBM 文件

<?php
// 創(chuàng)建空白圖像并添加文字
$im imagecreatetruecolor(12020);
$text_color imagecolorallocate($im2331491);
imagestring($im155,  'A Simple Text String'$text_color);

// 設(shè)置替換的前景色
$foreground_color imagecolorallocate($im25500);

// 保存圖像
imagexbm($imNULL$foreground_color);

// 釋放內(nèi)存
imagedestroy($im);
?>

注釋