note 56243 added to function.imagecolorat

From: Date: Sun, 28 Aug 2005 15:31:10 +0000
Subject: note 56243 added to function.imagecolorat
Groups: php.notes 
Request: Send a blank email to php-notes+get-94298@lists.php.net to get a copy of this message
Here is a contribution for change tint. function colorize($path_image, $red, $green, $blue) { $im = imagecreatefrompng($path_image); $pixel = array(); $n_im = imagecreatetruecolor(imagesx($im),imagesy($im)); $fond = imagecolorallocatealpha($n_im, 255, 255, 255, 0); imagefill($n_im, 0, 0, $fond); for($y=0;$y<imagesy($n_im);$y++) { for($x=0;$x<imagesx($n_im);$x++) { $rgb = imagecolorat($im, $x, $y); $pixel = imagecolorsforindex($im, $rgb); $r = min(round($red*$pixel['red']/169),255); $g = min(round($green*$pixel['green']/169),255); $b = min(round($blue*$pixel['blue']/169),255); $a = $pixel['alpha']; //echo('red : '.$pixel['red'].' => '.$r.', green : '.$pixel['green'].' => '.$g.', blue : '.$pixel['blue'].' => '.$b.', alpha : '.$pixel['alpha'].' => '.$a.'<br>'); $pixelcolor = imagecolorallocatealpha($n_im, $r, $g, $b, $a); imagealphablending($n_im, TRUE); imagesetpixel($n_im, $x, $y, $pixelcolor); } } imagepng($n_im,'test.png'); imagedestroy($n_im); } ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorat.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56243 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56243&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56243&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56243&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56243&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56243&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56243&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56243&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94298) next »