note 98234 added to function.imagefilter

From: Date: Thu, 03 Jun 2010 09:55:57 +0000
Subject: note 98234 added to function.imagefilter
Groups: php.notes 
Request: Send a blank email to php-notes+get-169843@lists.php.net to get a copy of this message
function imagefilterhue above is excellent, but it doesn't preserve alpha data , just a correction for preserving alpha ( in case you want to use for png with transparency) function imagefilterhue($im,$r,$g,$b){ $rgb = $r+$g+$b; $col = array($r/$rgb,$b/$rgb,$g/$rgb); $height = imagesy($im); $width = imagesx($im); // imagealphablending($im, false); // imagesavealpha($im, true); for($x=0; $x<$width; $x++){ for($y=0; $y<$height; $y++){ $rgb = ImageColorAt($im, $x, $y); $colors = imagecolorsforindex($im, $rgb); /* $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; */ $r = $colors['red']; $g = $colors['green']; $b = $colors['blue']; $alpha = $colors['alpha']; $newR = $r*$col[0] + $g*$col[1] + $b*$col[2]; $newG = $r*$col[2] + $g*$col[0] + $b*$col[1]; $newB = $r*$col[1] + $g*$col[2] + $b*$col[0]; imagesetpixel($im, $x, $y,imagecolorallocatealpha($im, $newR, $newG, $newB,$alpha)); } } } ---- Server IP: 69.147.83.197 Probable Submitter: 91.150.105.242 ---- Manual Page -- http://www.php.net/manual/en/function.imagefilter.php Edit -- https://master.php.net/note/edit/98234 Del: integrated -- https://master.php.net/note/delete/98234/integrated Del: useless -- https://master.php.net/note/delete/98234/useless Del: bad code -- https://master.php.net/note/delete/98234/bad+code Del: spam -- https://master.php.net/note/delete/98234/spam Del: non-english -- https://master.php.net/note/delete/98234/non-english Del: in docs -- https://master.php.net/note/delete/98234/in+docs Del: other reasons-- https://master.php.net/note/delete/98234 Reject -- https://master.php.net/note/reject/98234 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169843) next »