PHP/Graphics Image/imagecolorexact

Материал из Web эксперт
Версия от 10:05, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Color-retrieval functions could be combined into a custom function

   <source lang="html4strict">

<?php

   function getcolor($img, $red, $green, $blue) {
       $color = imagecolorexact($img, $red, $green, $blue);
       if($color == -1) {
           $color = imagecolorallocate($img, $red, $green, $blue);
           if($color == -1) {
               $color = imagecolorclosest($img, $red, $green, $blue);
           }
       }
       return $color;
   }

?>

 </source>