Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3643

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Allocate a color for an image</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagecharup.html">imagecharup</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagecolorallocatealpha.html">imagecolorallocatealpha</a></div>
 <div class="up"><a href="ref.image.html">GD and Image Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.imagecolorallocate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecolorallocate</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">imagecolorallocate</span> &mdash; <span class="dc-title">Allocate a color for an image</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecolorallocate-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>imagecolorallocate</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$red</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$green</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$blue</code></span>
   )</div>

  <p class="para rdfs-comment">
   Returns a color identifier representing the color composed of the given
   <acronym title="Red-Green-Blue">RGB</acronym> components.
  </p>
  <p class="para">
    <span class="function"><strong>imagecolorallocate()</strong></span> must be called
   to create each color that is to be used in the image represented
   by <em><code class="parameter">image</code></em>.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    The first call to  <span class="function"><strong>imagecolorallocate()</strong></span> fills
    the background color in palette-based images - images created using
     <span class="function"><a href="function.imagecreate.html" class="function">imagecreate()</a></span>.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecolorallocate-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>
<span class="term"><em><code class="parameter">
image</code></em></span><dd>
<p class="para">An image resource, returned by one of the image creation functions,
such as  <span class="function"><a href="function.imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a></span>.</p></dd>
</dt>

    <dt>

     <span class="term"><em><code class="parameter">red</code></em></span>
     <dd>

      <p class="para">Value of red component.</p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">green</code></em></span>
     <dd>

      <p class="para">Value of green component.</p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">blue</code></em></span>
     <dd>

      <p class="para">Value of blue component.</p>
     </dd>

    </dt>

   </dl>

   These parameters are integers between 0 and 255 or hexadecimals between 
   0x00 and 0xFF.
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecolorallocate-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   A color identifier or <strong><code>FALSE</code></strong> if the allocation failed.
  </p>
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">This function may
return Boolean <strong><code>FALSE</code></strong>, but may also return a non-Boolean value which
evaluates to <strong><code>FALSE</code></strong>. Please read the section on <a href="language.types.boolean.html" class="link">Booleans</a> for more
information. Use <a href="language.operators.comparison.html" class="link">the ===
operator</a> for testing the return value of this
function.</p></div>
 </div>

 <div class="refsect1 changelog" id="refsect1-function.imagecolorallocate-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.1.3</td>
       <td>
        Returns <strong><code>FALSE</code></strong> if the allocation failed. Previously
        <em>-1</em> was returned.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imagecolorallocate-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-3183">
    <p><strong>Example #1  <span class="function"><strong>imagecolorallocate()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreate</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;sets&nbsp;background&nbsp;to&nbsp;red<br /></span><span style="color: #0000BB">$background&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;sets&nbsp;some&nbsp;colors<br /></span><span style="color: #0000BB">$white&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$black&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;hexadecimal&nbsp;way<br /></span><span style="color: #0000BB">$white&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0xFF</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0xFF</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0xFF</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$black&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0x00</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0x00</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0x00</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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

 <div class="refsect1 seealso" id="refsect1-function.imagecolorallocate-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.imagecolorallocatealpha.html" class="function" rel="rdfs-seeAlso">imagecolorallocatealpha()</a> - Allocate a color for an image</span></li>
    <li class="member"> <span class="function"><a href="function.imagecolordeallocate.html" class="function" rel="rdfs-seeAlso">imagecolordeallocate()</a> - De-allocate a color for an image</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagecharup.html">imagecharup</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagecolorallocatealpha.html">imagecolorallocatealpha</a></div>
 <div class="up"><a href="ref.image.html">GD and Image Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>