array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagexbm.php', 1 => 'imagexbm', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imagewebp.php', 1 => 'imagewebp', ), 'next' => array ( 0 => 'function.iptcembed.php', 1 => 'iptcembed', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagexbm.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
imagexbm — 输出 XBM 图像到浏览器或文件
输出或保存 image
的 XBM 版本。
注意: imagexbm() 不应用任何填充,因此图片宽度必须是 8 的倍数。从 PHP 7.0.9 起此限制不再适用。
image
由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。
filename
string 格式,给出保存到文件的路径。如果为 null
,将直接输出原始图像流。
The filename
(without the .xbm extension) is also
used for the C identifiers of the XBM, whereby non
alphanumeric characters of the current locale are substituted by
underscores. If filename
is set to null
,
image
is used to build the C identifiers.
foreground_color
通过设置从 imagecolorallocate() 获得的标识符来使用此参数设置前景色。默认前景色是黑色。所有的其它颜色都视为背景。
版本 | 说明 |
---|---|
8.0.0 |
image 现在需要 GdImage 实例;之前需要有效的 gd resource。
|
8.0.0 |
foreground_color 现在允许为 null。
|
8.0.0 | 第四个参数未使用,已移除。 |
示例 #1 保存 XBM 文件
<?php
// 创建空白图像并添加文字
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// 保存图像
imagexbm($im, 'simpletext.xbm');
// 释放内存
imagedestroy($im);
?>
示例 #2 以不同前景色保存一个 XBM 文件
<?php
// 创建空白图像并添加文字
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// 设置替换的前景色
$foreground_color = imagecolorallocate($im, 255, 0, 0);
// 保存图像
imagexbm($im, NULL, $foreground_color);
// 释放内存
imagedestroy($im);
?>