PHP 8.3.4 Released!

imagecreatefromwbmp

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

imagecreatefromwbmp由文件或 URL 创建一个新图象。

说明

imagecreatefromwbmp(string $filename): GdImage|false

imagecreatefromwbmp() 返回图像标识符,代表从指定文件名获得的图像。

注意: WBMP 图像是无线位图(Wireless Bitmaps),不是 Windows 位图(Windows Bitmaps)。后者可以用 imagecreatefrombmp() 加载。

小技巧

如已启用fopen 包装器,在此函数中, URL 可作为文件名。关于如何指定文件名详见 fopen()。各种 wapper 的不同功能请参见 支持的协议和封装协议,注意其用法及其可提供的预定义变量。

参数

filename

WBMP 图像的路径。

返回值

成功后返回图象对象,失败后返回 false

更新日志

版本 说明
8.0.0 成功时,此函数现在返回 GDImage 实例;之前返回 resource

示例

示例 #1 在加载 WBMP 期间处理错误的示例

<?php
function LoadWBMP($imgname)
{
/* Attempt to open */
$im = @imagecreatefromwbmp($imgname);

/* See if it failed */
if(!$im)
{
/* Create a blank image */
$im = imagecreatetruecolor(150, 30);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);

imagefilledrectangle($im, 0, 0, 150, 30, $bgc);

/* Output an error message */
imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
}

return
$im;
}

header('Content-Type: image/vnd.wap.wbmp');

$img = LoadWBMP('bogus.image');

imagewbmp($img);
imagedestroy($img);
?>
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top