📄 function.imagecreatefromwbmp.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Create a new image from file or URL</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagecreatefromstring.html">imagecreatefromstring</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagecreatefromxbm.html">imagecreatefromxbm</a></div> <div class="up"><a href="ref.image.html">GD Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.imagecreatefromwbmp" class="refentry"> <div class="refnamediv"> <h1 class="refname">imagecreatefromwbmp</h1> <p class="verinfo">(PHP 4 >= 4.0.1, PHP 5)</p><p class="refpurpose"><span class="refname">imagecreatefromwbmp</span> — <span class="dc-title">Create a new image from file or URL</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><b><b>imagecreatefromwbmp</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span> )</div> <p class="para rdfs-comment"> <b>imagecreatefromwbmp()</b> returns an image identifier representing the image obtained from the given filename. </p> <div class="tip"><b class="tip">Tip</b><p class="simpara">A URL can be used as afilename with this function if the <a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">fopen wrappers</a> have been enabled.See <a href="function.fopen.html" class="function">fopen()</a> for more details on how to specifythe filename and <a href="wrappers.html" class="xref">List of Supported Protocols/Wrappers</a> for a list of supportedURL protocols.</p></div> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">filename</tt></i></span> <dd> <p class="para"> Path to the WBMP image. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an image resource identifier on success, <b><tt>FALSE</tt></b> on errors. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <div class="example"> <p><b>Example #1 Example to handle an error during loading of a WBMP</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">LoadWBMP</span><span style="color: #007700">(</span><span style="color: #0000BB">$imgname</span><span style="color: #007700">)<br />{<br /> </span><span style="color: #FF8000">/* Attempt to open */<br /> </span><span style="color: #0000BB">$im </span><span style="color: #007700">= @</span><span style="color: #0000BB">imagecreatefromwbmp</span><span style="color: #007700">(</span><span style="color: #0000BB">$imgname</span><span style="color: #007700">);<br /><br /> </span><span style="color: #FF8000">/* See if it failed */<br /> </span><span style="color: #007700">if(!</span><span style="color: #0000BB">$im</span><span style="color: #007700">)<br /> {<br /> </span><span style="color: #FF8000">/* Create a blank image */<br /> </span><span style="color: #0000BB">$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatetruecolor </span><span style="color: #007700">(</span><span style="color: #0000BB">20</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$bgc </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$tc </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /> </span><span style="color: #0000BB">imagefilledrectangle</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">$bgc</span><span style="color: #007700">);<br /><br /> </span><span style="color: #FF8000">/* Output an error message */<br /> </span><span style="color: #0000BB">imagestring</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #DD0000">'Error loading ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$imgname</span><span style="color: #007700">, </span><span style="color: #0000BB">$tc</span><span style="color: #007700">);<br /> }<br /><br /> return </span><span style="color: #0000BB">$im</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-Type: image/png'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$img </span><span style="color: #007700">= </span><span style="color: #0000BB">LoadPNG</span><span style="color: #007700">(</span><span style="color: #DD0000">'bogus.image'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagwbmp</span><span style="color: #007700">(</span><span style="color: #0000BB">$img</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$img</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: <span class="simpara">WBMP support is only available if PHP was compiled against GD-1.8 or later.</span></p></blockquote> <div class="warning"><b class="warning">Warning</b><p class="para">Windows versions of PHPprior to PHP 4.3.0 do not support access of remote files via this function,even if <a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">allow_url_fopen</a> is enabled.</p></div> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagecreatefromstring.html">imagecreatefromstring</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagecreatefromxbm.html">imagecreatefromxbm</a></div> <div class="up"><a href="ref.image.html">GD Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -