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

imagewbmp

(PHP 4 >= 4.0.1, PHP 5, PHP 7)

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

描述

代码语言:javascript
复制
bool imagewbmp ( resource $image [, mixed $to [, int $foreground ]] )

imagewbmp()输出或保存给定的WBMP版本image

参数

代码语言:txt
复制
`image`   

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

to

路径或打开的流资源(在此函数返回后自动关闭)将文件保存到。 如果没有设置或NULL,则原始图像流将被直接输出。

foreground

您可以通过设置从imagecolorallocate()获取的标识符来使用此参数设置前景色。默认的前景色是黑色的。

返回值

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

更新日志

描述

5.4.0

增加了对将流资源传递给to的支持。

例子

示例#1输出WBMP图像

代码语言: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 the content type header - in this case image/vnd.wap.wbmp
// Hint: see image_type_to_mime_type() for content-types
header('Content-Type: image/vnd.wap.wbmp');

// Output the image
imagewbmp($im);

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

例#2保存WBMP图像

代码语言: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
imagewbmp($im, 'simpletext.wbmp');

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

示例#3使用不同的前景输出图像

代码语言: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 the content type header - in this case image/vnd.wap.wbmp
// Hint: see image_type_to_mime_type() for content-types
header('Content-Type: image/vnd.wap.wbmp');

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

imagewbmp($im, NULL, $foreground_color);

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

扩展内容

  • image2wbmp() - 将图像输出到浏览器或文件
  • imagepng() - 将PNG图像输出到浏览器或文件
  • imagegif() - 将图像输出到浏览器或文件
  • imagejpeg() - 将图像输出到浏览器或文件
  • imagetypes() - 返回此PHP构建支持的图像类型

← imagetypes

imagewebp →

扫码关注腾讯云开发者

领取腾讯云代金券