<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.image.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.imagebmp.php',
    1 => 'imagebmp',
    2 => 'Output a BMP image to browser or file',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD 和图像处理 函数',
  ),
  'prev' => 
  array (
    0 => 'function.imageavif.php',
    1 => 'imageavif',
  ),
  'next' => 
  array (
    0 => 'function.imagechar.php',
    1 => 'imagechar',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/image/functions/imagebmp.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagebmp" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagebmp</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">imagebmp</span> &mdash; <span class="dc-title">Output a BMP image to browser or file</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.imagebmp-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagebmp</strong></span>(<span class="methodparam"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span> <code class="parameter">$image</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$file</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$compressed</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Outputs or saves a BMP version of the given <code class="parameter">image</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.imagebmp-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    <dt>
<code class="parameter">image</code></dt><dd><p class="para">由图象创建函数(例如<span class="function"><a href="function.imagecreatetruecolor.php" class="function">imagecreatetruecolor()</a></span>)返回的 
<span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span> 对象。</p></dd>
    
     <dt><code class="parameter">file</code></dt>
     <dd>
      <p class="para">文件保存的路径或者已打开的流资源（此方法返回后自动关闭该流资源），如果未设置或为 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>，将会直接输出原始图象流。</p>
      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <p class="para">
        <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> is invalid if the <code class="parameter">compressed</code> arguments is
        not used.
       </p>
      </p></blockquote>
     </dd>
    
    
     <dt><code class="parameter">compressed</code></dt>
     <dd>
      <p class="para">
       Whether the BMP should be compressed with run-length encoding (RLE), or not.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagebmp-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>， 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
  <div class="caution"><strong class="caution">警告</strong><p class="simpara">如果 libgd 输出图像失败，函数会返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>。</p></div>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagebmp-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">image</code> 现在需要 <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span> 实例；之前需要有效的 <code class="literal">gd</code> <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       The type of <code class="parameter">compressed</code> is <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> now; formerly it was <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>



 <div class="refsect1 examples" id="refsect1-function.imagebmp-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 Saving a BMP file</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Create a blank image and add some text<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">120</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$text_color </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">233</span><span style="color: #007700">, </span><span style="color: #0000BB">14</span><span style="color: #007700">, </span><span style="color: #0000BB">91</span><span style="color: #007700">);<br /><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">'BMP with PHP'</span><span style="color: #007700">, </span><span style="color: #0000BB">$text_color</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Save the image<br /></span><span style="color: #0000BB">imagebmp</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #DD0000">'php.bmp'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

</div><?php manual_footer($setup); ?>