略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: imagexbm

2024-04-28

imagexbm

(PHP 5, PHP 7, PHP 8)

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

说明

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

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

参数

image

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

filename

文件保存的路径或者已打开的流资源(此方法返回后自动关闭该流资源),如果未设置或为 null,将会直接输出原始图象流。

foreground

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

返回值

成功时返回 true, 或者在失败时返回 false

范例

示例 #1 保存一个 XBM 文件

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

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

// 释放内存
imagedestroy($im);
?>

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

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

// 设置替换的前景色
$foreground_color imagecolorallocate($im25500);

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

// 释放内存
imagedestroy($im);
?>

注释

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.imagexbm.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3