note 27707 deleted from function.imagecolorallocate by didou

From: Date: Tue, 01 Jul 2003 08:21:48 +0000
Subject: note 27707 deleted from function.imagecolorallocate by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-51254@lists.php.net to get a copy of this message
Note Submitter: jeffrey@jhu.edu ---- 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

« previous php.notes (#51254) next »