<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.imagecolortransparent.php',
    1 => 'imagecolortransparent',
    2 => 'D&eacute;finit la couleur transparente',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'Fonctions GD et images',
  ),
  'prev' => 
  array (
    0 => 'function.imagecolorstotal.php',
    1 => 'imagecolorstotal',
  ),
  'next' => 
  array (
    0 => 'function.imageconvolution.php',
    1 => 'imageconvolution',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/image/functions/imagecolortransparent.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagecolortransparent" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecolortransparent</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagecolortransparent</span> &mdash; <span class="dc-title">Définit la couleur transparente</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecolortransparent-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecolortransparent</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.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$color</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Récupère ou définit la couleur transparente pour l&#039;<code class="parameter">image</code> fournie.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecolortransparent-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
<dt><code class="parameter">image</code></dt><dd><p class="para">
 Un objet <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span>, retournée par une des fonctions de
 création d&#039;images, comme <span class="function"><a href="function.imagecreatetruecolor.php" class="function">imagecreatetruecolor()</a></span>.
</p></dd>
    
     <dt><code class="parameter">color</code></dt>
     <dd>
      <p class="para">
       Un identificateur de couleur créé avec <span class="function"><a href="function.imagecolorallocate.php" class="function">imagecolorallocate()</a></span>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagecolortransparent-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   L&#039;identifiant de la nouvelle couleur transparente (ou l&#039;actuelle,
   si aucune n&#039;est spécifiée) est retourné. Si le paramètre <code class="parameter">color</code>
   est <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, et que l&#039;image n&#039;a pas de couleur transparente,
   l&#039;identifiant retourné sera <code class="literal">-1</code>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagecolortransparent-changelog">
  <h3 class="title">Historique</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">image</code> attend une instance de <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span> désormais;
  auparavant, une <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="literal">gd</code> était attendue.
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">color</code> est désormais nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecolortransparent-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>imagecolortransparent()</strong></span></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">// Création d'une image de 55x30<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">55</span><span style="color: #007700">, </span><span style="color: #0000BB">30</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$red </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">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$black </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: #FF8000">// On rend l'arrière-plan transparent<br /></span><span style="color: #0000BB">imagecolortransparent</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">$black</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// On dessine un rectangle rouge<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">4</span><span style="color: #007700">, </span><span style="color: #0000BB">4</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #0000BB">25</span><span style="color: #007700">, </span><span style="color: #0000BB">$red</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// On sauvegarde l'image<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #DD0000">'./imagecolortransparent.png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Résultat de l&#039;exemple ci-dessus est similaire à :</p></div>
    <div class="mediaobject">
     
     <div class="imageobject">
      <img src="images/21009b70229598c6a80eef8b45bf282b-imagecolortransparent.png" alt="Affichage de l'exemple : imagecolortransparent()" width="55" height="30" />
     </div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.imagecolortransparent-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    La transparence est copiée uniquement avec la fonction 
    <span class="function"><a href="function.imagecopymerge.php" class="function">imagecopymerge()</a></span> et les images en couleur vraies,
    non pas avec la fonction <span class="function"><a href="function.imagecopy.php" class="function">imagecopy()</a></span> ou les images
    de palette.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    La couleur de transparence est une propriété de l&#039;image, elle n&#039;est pas
    une propriété de la couleur. Une fois que l&#039;on a défini la couleur de
    transparence, chaque région de l&#039;image de cette couleur que l&#039;on a
    dessiné précédemment sera transparente.
   </p>
  </p></blockquote>
 </div>

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