Показать сообщение отдельно

  #6  
Старый 18.10.2009, 22:11
heretic1990
Постоянный
Регистрация: 02.07.2008
Сообщений: 472
С нами: 9399011

Репутация: 444
По умолчанию

Данная функция позволяет конвертировать цветное изображение в черно-белое.

PHP код:
<?php
function MakeColoursGrey($im,$col){
 
$total=ImageColorsTotal($im);
 for(
$i=0;$i<$total;$i++){
   
$old=ImageColorsForIndex($im,$i);
  
   
$commongrey=(int)($old[red]+$old[green]+$old[blue])/3;
   if(!
$col){
    
ImageColorSet($im,$i,$commongrey,$commongrey,$commongrey);
   }elseif(
$col==1){
    
ImageColorSet($im,$i,$commongrey,0,0);
   }elseif(
$col==2){
    
ImageColorSet($im,$i,0,$commongrey,0);
   }elseif(
$col==3){
    
ImageColorSet($im,$i,0,0,$commongrey);
   }
 }
}

$img=imagecreatefromgif($src);

MakeColoursGrey($img,$col);

Header("Content-Type: image/gif");

ImageGif($img);
?>
 
Ответить с цитированием