<?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.imagecolorat.php',
    1 => 'imagecolorat',
    2 => 'Retourne l\'index de la couleur d\'un pixel donn&eacute;',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'Fonctions GD et images',
  ),
  'prev' => 
  array (
    0 => 'function.imagecolorallocatealpha.php',
    1 => 'imagecolorallocatealpha',
  ),
  'next' => 
  array (
    0 => 'function.imagecolorclosest.php',
    1 => 'imagecolorclosest',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/image/functions/imagecolorat.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagecolorat" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecolorat</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagecolorat</span> &mdash; <span class="dc-title">Retourne l&#039;index de la couleur d&#039;un pixel donné</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecolorat-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecolorat</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"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$x</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$y</code></span>): <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">
   Retourne l&#039;index de la couleur du pixel situé aux coordonnées spécifiées,
   dans l&#039;image <code class="parameter">image</code>.
  </p>
  <p class="para">
   Si l&#039;image
   est une image en TrueColor, cette fonction retourne la valeur RGB
   du pixel, sous forme d&#039;un entier. Utiliser les opérateurs de bits et les
   masques pour distinguer le rouge, du vert et du bleu : 
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecolorat-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">x</code></dt>
     <dd>
      <p class="para">
       X : coordonnée du point.
      </p>
     </dd>
    
    
     <dt><code class="parameter">y</code></dt>
     <dd>
      <p class="para">
       Y : coordonnée du point.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecolorat-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne l&#039;index de la couleur  ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
  </p>
  <div class="warning"><strong class="warning">Avertissement</strong><p class="simpara">
 Cette fonction peut retourner <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, mais elle peut aussi retourner une valeur équivalent à <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
 Veuillez lire la section sur les <a href="language.types.boolean.php" class="link">booléens</a> pour plus d&#039;informations.
 Utilisez l&#039;<a href="language.operators.comparison.php" class="link">opérateur ===</a>
 pour tester la valeur de retour exacte de cette fonction.
</p></div>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagecolorat-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>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecolorat-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Accès aux valeurs RGB</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatefrompng</span><span style="color: #007700">(</span><span style="color: #DD0000">"php.png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rgb </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorat</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">15</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= (</span><span style="color: #0000BB">$rgb </span><span style="color: #007700">&gt;&gt; </span><span style="color: #0000BB">16</span><span style="color: #007700">) &amp; </span><span style="color: #0000BB">0xFF</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$g </span><span style="color: #007700">= (</span><span style="color: #0000BB">$rgb </span><span style="color: #007700">&gt;&gt; </span><span style="color: #0000BB">8</span><span style="color: #007700">) &amp; </span><span style="color: #0000BB">0xFF</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">$rgb </span><span style="color: #007700">&amp; </span><span style="color: #0000BB">0xFF</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">, </span><span style="color: #0000BB">$g</span><span style="color: #007700">, </span><span style="color: #0000BB">$b</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="example-contents screen">
<div class="examplescode"><pre class="examplescode">int(119)
int(123)
int(180)</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>Exemple #2 Valeurs RVB lisibles en utilisant la fonction
     <span class="function"><a href="function.imagecolorsforindex.php" class="function">imagecolorsforindex()</a></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatefrompng</span><span style="color: #007700">(</span><span style="color: #DD0000">"php.png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rgb </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorat</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">15</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$colors </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorsforindex</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">$rgb</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$colors</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="example-contents screen">
<div class="examplescode"><pre class="examplescode">array(4) {
  [&quot;red&quot;]=&gt;
  int(119)
  [&quot;green&quot;]=&gt;
  int(123)
  [&quot;blue&quot;]=&gt;
  int(180)
  [&quot;alpha&quot;]=&gt;
  int(127)
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imagecolorat-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagecolorset.php" class="function" rel="rdfs-seeAlso">imagecolorset()</a> - Change la couleur dans une palette &agrave; l'index donn&eacute;</span></li>
   <li><span class="function"><a href="function.imagecolorsforindex.php" class="function" rel="rdfs-seeAlso">imagecolorsforindex()</a> - Retourne la couleur associ&eacute;e &agrave; un index</span></li>
   <li><span class="function"><a href="function.imagesetpixel.php" class="function" rel="rdfs-seeAlso">imagesetpixel()</a> - Dessine un pixel</span></li>
  </ul>
 </div>

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