• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • imagecreatefromwbmp()

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

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

    说明

    imagecreatefromwbmp(string $filename): resource

    imagecreatefromwbmp()返回一图像标识符,代表了从给定的文件名取得的图像。

    Tip

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

    参数

    $filename

    WBMP 图像的路径。

    返回值

    成功后返回图象资源,失败后返回FALSE

    范例

    处理创建 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);
    ?>
    

    注释

    Note:WBMP 支持仅在 PHP 与 GD-1.8 或更高版本一起编译时可用。

    Warning

    Windows 版本的 PHP 在 4.3.0版之前不支持通过此函数访问远程文件,即使已经启用allow_url_fopen.