note 36668 added to function.imagecopymergegray

From: Date: Sat, 18 Oct 2003 04:08:23 +0000
Subject: note 36668 added to function.imagecopymergegray
Groups: php.notes 
Request: Send a blank email to php-notes+get-58784@lists.php.net to get a copy of this message
# very fast way to generate a grayscal- # image from a true color image #... # --- quick grayscale image for ($y = 0; $y <$img_height; $y++) { for ($x = 0; $x <$img_width; $x++) { # here we extract the green from # the pixel at x,y , to use it as gray value $gray = (ImageColorAt($image, $x, $y) >> 8) & 0xFF; # a more exact way would be this: # $rgb = ImageColorAt($image, $x, $y); # $red = ($rgb >> 16) & 0xFF; # $green = (trgb >> 8) & 0xFF; # $blue = $rgb & 0xFF; # $gray = (int)(($red+$green+$blue)/4); # and here we set the new pixel/color imagesetpixel ($image, $x, $y, ImageColorAllocate ($image, $gray,$gray,$gray)); } } # ... ---- Manual Page -- http://www.php.net/manual/en/function.imagecopymergegray.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36668 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36668&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36668&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58784) next »