<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.imagecolorat.php',
    1 => 'imagecolorat',
    2 => 'Get the index of the color of a pixel',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'Функції GD та Image',
  ),
  'prev' => 
  array (
    0 => 'function.imagecolorallocatealpha.php',
    1 => 'imagecolorallocatealpha',
  ),
  'next' => 
  array (
    0 => 'function.imagecolorclosest.php',
    1 => 'imagecolorclosest',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    '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">Get the index of the color of a pixel</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecolorat-description">
  <h3 class="title">Опис</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">
   Returns the index of the color of the pixel at the
   specified location in the image specified by <code class="parameter">image</code>.
  </p>
  <p class="para">
   If the image is a
   truecolor image, this function returns the RGB value of that pixel as
   integer. Use bitshifting and masking to access the distinct red, green and blue
   component values:
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecolorat-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    <dt><code class="parameter">image</code></dt><dd><p class="para">Об&#039;єкт
<span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span>, що повертається однією з функцій створення
зображення, такою як
<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-coordinate of the point.
      </p>
     </dd>
    
    
     <dt><code class="parameter">y</code></dt>
     <dd>
      <p class="para">
       y-coordinate of the point.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecolorat-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the index of the color  або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
  <div class="warning"><strong class="warning">Увага</strong><p class="simpara">Ця функція може
повертати як логічне <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, так і не логічне значення, яке прирівнюється до
<strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>. Докладніше про це описано в розділі <a href="language.types.boolean.php" class="link">Логічні типи даних</a>. Для перевірки
значення, яке повертає ця функція, використовується <a href="language.operators.comparison.php" class="link">оператор ===</a>.</p></div>
 </div>


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

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecolorat-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 Access distinct RGB values</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 /><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>Поданий вище приклад виведе щось
схоже на:</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>Приклад #2 Human-readable RGB values using <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>Поданий вище приклад виведе щось
схоже на:</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">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagecolorset.php" class="function" rel="rdfs-seeAlso">imagecolorset()</a> - Set the color for the specified palette index</span></li>
   <li><span class="function"><a href="function.imagecolorsforindex.php" class="function" rel="rdfs-seeAlso">imagecolorsforindex()</a> - Get the colors for an index</span></li>
   <li><span class="function"><a href="function.imagesetpixel.php" class="function" rel="rdfs-seeAlso">imagesetpixel()</a> - Set a single pixel</span></li>
  </ul>
 </div>

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