牛牛在线工具

imagexbm()

收录 8868 个 PHP 函数,含用途说明与用法示例。

imagexbm()

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

函数名:imagexbm() 适用版本:PHP 4, PHP 5, PHP 7 函数描述:imagexbm() 函数用于将 XBM 图像输出到浏览器或文件。 语法:bool imagexbm ( resource $image , string $filename [, int $foreground ] ) 参数: $image:必需,表示图像资源,使用 imagecreatefromxbm() 创建。 $filename:必需,表示输出的文件名或路径。如果未设置或为 NULL,则直接输出到浏览器。 $foreground:可选,表示前景颜色的索引值(0-255)。默认为黑色。 返回值:成功时返回 true,失败时返回 false。 示例: 输出到浏览器: $width = 100; $height = 100; $image = imagecreate($width, $height); $foreground = imagecolorallocate($image, 0, 0, 0); // 黑色 imagexbm($image, NULL, $foreground); imagedestroy($image); 输出到文件: $width = 100; $height = 100; $image = imagecreate($width, $height); $foreground = imagecolorallocate($image, 0, 0, 0); // 黑色 imagexbm($image, 'output.xbm', $foreground); imagedestroy($image); 以上示例中,我们创建了一个宽高为 100 像素的黑色图像,并通过 imagexbm() 函数将其输出到浏览器或文件中。如果指定了文件名,则会将图像保存为 XBM 文件。否则,图像将直接输出到浏览器。