文字

imagexbm

(PHP 5, PHP 7)

imagexbm将 XBM 图像输出到浏览器或文件

说明

bool imagexbm ( resource $image , string $filename [, int $foreground ] )

XBM 图像 image 输出到浏览器或文件

参数

image

由图象创建函数(例如 imagecreatetruecolor() )返回的图象资源。

filename

文件保存的路径,如果未设置或为 NULL ,将会直接输出原始图象流。

foreground

你可以从 imagecolorallocate() 分配一个颜色,并设置为该前景色参数。 默认颜色是黑色。

返回值

成功时返回 TRUE , 或者在失败时返回 FALSE

范例

Example #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 );
?>

Example #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 );
?>

注释

Note: 此函数仅在与 GD 库捆绑编译的 PHP 版本中可用。

上一篇: 下一篇: