note 27707 added to function.imagecolorallocate

From: Date: Mon, 16 Dec 2002 18:17:48 +0000
Subject: note 27707 added to function.imagecolorallocate
Groups: php.notes 
Request: Send a blank email to php-notes+get-40971@lists.php.net to get a copy of this message
faceman at flevonet dot nl wrote: " 23-Aug-2002 05:04 " No, it doesn't ... here a function I wrote: <snip!> Why is your function so goshawful complicated? Why not just do function ImageColorAllocateHex( $image, $hex ) { return ImageColorAllocate( $image, array(hexdec( substr($bgcolor, 0, 2) ), hexdec( substr($bgcolor, 2, 2) ), hexdec( substr($bgcolor, 4, 2) )); } Where, for example, $image=<image_resource_id> AND $hex="ffffff" or other hex value. Whats the deal with the algorithm " for( $i=0; $i<3; $i++ ) { $temp = substr($hex, 2*$i, 2); $rgb[$i] = 16 * hexdec( substr($temp, 0, 1) ) + hexdec(substr($temp, 1, 1)); }"?? The individual decimal values can be created by just doing a simple hexdec() conversion, no? Why all the extra addition and multiplcation by 16, etc.?? okay, later all... -Jeff S -- http://www.php.net/manual/en/function.imagecolorallocate.php http://master.php.net/manage/user-notes.php?action=edit+27707 http://master.php.net/manage/user-notes.php?action=delete+27707 http://master.php.net/manage/user-notes.php?action=reject+27707

« previous php.notes (#40971) next »