(PHP 5, PHP 7, PHP 8)
imagexbm — 输出 XBM 图像到浏览器或文件
   输出或保存 image 的 XBM 版本。
  
注意: imagexbm() 不应用任何填充,因此图片宽度必须是 8 的倍数。从 PHP 7.0.9 起此限制不再适用。
image由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。
filenamestring 格式,给出保存到文件的路径。如果为 null,将直接输出原始图像流。
       filename(不带 .xbm 扩展名)也用于 XBM 的 C
       标识符,其中当前区域设置的非字母数字字符将由下划线替换。如果 filename
       设置为 null,则 image 用于构建 C 标识符。
      
foreground_color通过设置从 imagecolorallocate() 获得的标识符来使用此参数设置前景色。默认前景色是黑色。所有的其它颜色都视为背景。
| 版本 | 说明 | 
|---|---|
| 8.0.0 | image现在需要 GdImage 实例;之前需要有效的gdresource。 | 
| 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');
?>
示例 #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);
?>