首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

imagexbm

(PHP 5, PHP 7)

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

描述

代码语言:javascript
复制
bool imagexbm ( resource $image , string $filename [, int $foreground ] )

输出或保存给定的XBM版本image

注意imagexbm()不应用任何填充,因此图像宽度必须是8的倍数。从PHP 5.6.24和7.0.9开始,此限制不再适用。

参数

代码语言:txt
复制
`image`   

一个图像资源,由图像创建函数之一返回,如imagecreatetruecolor()。

filename

保存文件的路径。 如果没有设置或NULL,则原始图像流将被直接输出。

文件名(不带.xbm扩展名)也用于XBM的C标识符,因此当前语言环境的非字母数字字符由下划线替代。 如果filename设置为NULL,则使用image来构建C标识符。

foreground

您可以通过设置从imagecolorallocate()获取的标识符来使用此参数设置前景色。默认的前景色是黑色的。所有其他颜色被视为背景。

返回值

成功返回TRUE或失败时返回FALSE。

例子

示例#1保存XBM文件

代码语言:javascript
复制
<?php
// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);

// Save the image
imagexbm($im, 'simpletext.xbm');

// Free up memory
imagedestroy($im);
?>

示例#2使用不同的前景色保存XBM文件

代码语言:javascript
复制
<?php
// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);

// Set a replacement foreground color
$foreground_color = imagecolorallocate($im, 255, 0, 0);

// Save the image
imagexbm($im, NULL, $foreground_color);

// Free up memory
imagedestroy($im);
?>

注意

← imagewebp

iptcembed →

扫码关注腾讯云开发者

领取腾讯云代金券