<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.imagecolorallocatealpha.php',
    1 => 'imagecolorallocatealpha',
    2 => 'Allocate a color for an image',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'GD- und Image-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.imagecolorallocate.php',
    1 => 'imagecolorallocate',
  ),
  'next' => 
  array (
    0 => 'function.imagecolorat.php',
    1 => 'imagecolorat',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/image/functions/imagecolorallocatealpha.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagecolorallocatealpha" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecolorallocatealpha</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.2, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagecolorallocatealpha</span> &mdash; <span class="dc-title">Allocate a color for an image</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecolorallocatealpha-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecolorallocatealpha</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span> <code class="parameter">$image</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$red</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$green</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$blue</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$alpha</code></span><br>): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>imagecolorallocatealpha()</strong></span> behaves identically to
   <span class="function"><a href="function.imagecolorallocate.php" class="function">imagecolorallocate()</a></span> with the addition of the transparency
   parameter <code class="parameter">alpha</code>.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecolorallocatealpha-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    <dt>
<code class="parameter">image</code></dt><dd><p class="para">Ein <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span>-Objekt, das von einer der Funktionen zur Bilderzeugung, z. B.
<span class="function"><a href="function.imagecreatetruecolor.php" class="function">imagecreatetruecolor()</a></span>, zurückgegeben wurde.</p></dd>
    
     <dt><code class="parameter">red</code></dt>
     <dd>
      <p class="para">Wert der Rotkomponente.</p>
     </dd>
    
    
     <dt><code class="parameter">green</code></dt>
     <dd>
      <p class="para">Wert der Grünkomponente.</p>
     </dd>
    
    
     <dt><code class="parameter">blue</code></dt>
     <dd>
      <p class="para">Wert der Blaukomponente.</p>
     </dd>
    
    
     <dt><code class="parameter">alpha</code></dt>
     <dd>
      <p class="para">
       A value between <code class="literal">0</code> and <code class="literal">127</code>.
       <code class="literal">0</code> indicates completely opaque while 
       <code class="literal">127</code> indicates completely transparent.
      </p>
     </dd>
    
   </dl>
   The <code class="parameter">red</code>, <code class="parameter">green</code>
   and <code class="parameter">blue</code> parameters are integers
   between 0 and 255 or hexadecimals between 0x00 and 0xFF.
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecolorallocatealpha-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   A color identifier or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if the allocation failed.
  </p>
  <div class="warning"><strong class="warning">Warnung</strong><p class="simpara">Diese Funktion kann sowohl das
boolsche <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückliefern, als auch einen nicht-boolschen Wert, welcher zu <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> ausgewertet wird.
Weitere Informationen entnehmen Sie bitte dem Abschnitt über die
<a href="language.types.boolean.php" class="link"> boolschen Typen</a>. Benutzen Sie deshalb
<a href="language.operators.comparison.php" class="link">den === Operator</a>,
um den Rückgabewert dieser Funktion zu überprüfen.</p></div>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagecolorallocatealpha-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">image</code> erwartet nun eine
  <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span>-Instanz; vorher wurde eine gültige
  <code class="literal">gd</code>-<span class="type">Ressource</span> erwartet.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecolorallocatealpha-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="example-1">
   <p><strong>Beispiel #1 Example of using <span class="function"><strong>imagecolorallocatealpha()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$size </span><span style="color: #007700">= </span><span style="color: #0000BB">300</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$image</span><span style="color: #007700">=</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">$size</span><span style="color: #007700">, </span><span style="color: #0000BB">$size</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// something to get a white background with black border<br /></span><span style="color: #0000BB">$back </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</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">$border </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</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 /></span><span style="color: #0000BB">imagefilledrectangle</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</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">$size </span><span style="color: #007700">- </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">$size </span><span style="color: #007700">- </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">$back</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagerectangle</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</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">$size </span><span style="color: #007700">- </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">$size </span><span style="color: #007700">- </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">$border</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$yellow_x </span><span style="color: #007700">= </span><span style="color: #0000BB">100</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$yellow_y </span><span style="color: #007700">= </span><span style="color: #0000BB">75</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$red_x    </span><span style="color: #007700">= </span><span style="color: #0000BB">120</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$red_y    </span><span style="color: #007700">= </span><span style="color: #0000BB">165</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$blue_x   </span><span style="color: #007700">= </span><span style="color: #0000BB">187</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$blue_y   </span><span style="color: #007700">= </span><span style="color: #0000BB">125</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$radius   </span><span style="color: #007700">= </span><span style="color: #0000BB">150</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// allocate colors with alpha values<br /></span><span style="color: #0000BB">$yellow </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocatealpha</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</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">0</span><span style="color: #007700">, </span><span style="color: #0000BB">75</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$red    </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocatealpha</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">, </span><span style="color: #0000BB">255</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">75</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$blue   </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocatealpha</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</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">255</span><span style="color: #007700">, </span><span style="color: #0000BB">75</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// drawing 3 overlapped circle<br /></span><span style="color: #0000BB">imagefilledellipse</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">, </span><span style="color: #0000BB">$yellow_x</span><span style="color: #007700">, </span><span style="color: #0000BB">$yellow_y</span><span style="color: #007700">, </span><span style="color: #0000BB">$radius</span><span style="color: #007700">, </span><span style="color: #0000BB">$radius</span><span style="color: #007700">, </span><span style="color: #0000BB">$yellow</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagefilledellipse</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">, </span><span style="color: #0000BB">$red_x</span><span style="color: #007700">, </span><span style="color: #0000BB">$red_y</span><span style="color: #007700">, </span><span style="color: #0000BB">$radius</span><span style="color: #007700">, </span><span style="color: #0000BB">$radius</span><span style="color: #007700">, </span><span style="color: #0000BB">$red</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagefilledellipse</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">, </span><span style="color: #0000BB">$blue_x</span><span style="color: #007700">, </span><span style="color: #0000BB">$blue_y</span><span style="color: #007700">, </span><span style="color: #0000BB">$radius</span><span style="color: #007700">, </span><span style="color: #0000BB">$radius</span><span style="color: #007700">, </span><span style="color: #0000BB">$blue</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// don't forget to output a correct header!<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: #FF8000">// and finally, output the result<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt
eine ähnliche Ausgabe wie:</p></div>
   <div class="mediaobject">
    
    <div class="imageobject">
     <img src="images/21009b70229598c6a80eef8b45bf282b-imagecolorallocatealpha.png" alt="Output of example : Example of using imagecolorallocatealpha()" width="300" height="300" />
    </div>
   </div>
  </div>
  <div class="example" id="imagecolorallocatealpha.example.convert">
   <p><strong>Beispiel #2 Convert typical alpha values for use with <span class="function"><strong>imagecolorallocatealpha()</strong></span></strong></p>
   <div class="example-contents"><p>
    Usually alpha values of <code class="literal">0</code> designate fully transparent pixels,
    and the alpha channel has 8 bits. To convert such alpha values to be compatible
    with <span class="function"><strong>imagecolorallocatealpha()</strong></span>, some simple arithmetic is
    sufficient:
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$alpha8 </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #FF8000">// fully transparent<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">127 </span><span style="color: #007700">- (</span><span style="color: #0000BB">$alpha8 </span><span style="color: #007700">&gt;&gt; </span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$alpha8 </span><span style="color: #007700">= </span><span style="color: #0000BB">255</span><span style="color: #007700">; </span><span style="color: #FF8000">// fully opaque<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">127 </span><span style="color: #007700">- (</span><span style="color: #0000BB">$alpha8 </span><span style="color: #007700">&gt;&gt; </span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">int(127)
int(0)</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.imagecolorallocatealpha-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagecolorallocate.php" class="function" rel="rdfs-seeAlso">imagecolorallocate()</a> - Alloziert eine Farbe f&uuml;r eine Grafik</span></li>
   <li><span class="function"><a href="function.imagecolordeallocate.php" class="function" rel="rdfs-seeAlso">imagecolordeallocate()</a> - L&ouml;scht eine Farbdefinition</span></li>
  </ul>
 </div>

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