note 58756 added to function.imagecolorallocate

From: Date: Tue, 15 Nov 2005 09:49:46 +0000
Subject: note 58756 added to function.imagecolorallocate
Groups: php.notes 
Request: Send a blank email to php-notes+get-98577@lists.php.net to get a copy of this message
Another more general variation on the theme using the same naming conventions as the hexdec and dechex built-in functions ... Prototype: array hexrgb ( string hex_string ) Returns: An associative array of the RGB components specified in hex_string. hexrgb() example: <?php $rgb = hexrgb("0xAABBCC"); print_r($rgb); ?> Output is: Array ( [red] => 170 [green] => 187 [blue] => 204 ) Implementation: <?php function hexrgb ($hexstr) { $int = hexdec($hexstr); return array("red" => 0xFF & ($int >> 0x10), "green" => 0xFF & ($int >> 0x8), "blue" => 0xFF & $int); } ?> The output of hexdec can then be passed to imagecolorallocate and manipulated as required. ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58756 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58756&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58756&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58756&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58756&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58756&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58756&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58756&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58756&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98577) next »