note 78399 rejected from function.imagecolorallocate by felipe

From: Date: Mon, 24 Dec 2007 02:58:02 +0000
Subject: note 78399 rejected from function.imagecolorallocate by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133961@lists.php.net to get a copy of this message
Note Submitter: marszysz at gmail dot com ---- hex2color once again: this is the simplest possible method :) <?php $htmlcolor = "FF9900"; $color = hexdec ($htmlcolor); ?> Let's face the truth: for the truecolor images, imagecolorallocate doesn't allocate anything, but simply makes a hex representation of color, treats it as one large hex number, and calculates an int value from it. Oh, it's probably a good idea to validate $htmlcolor first, like: <?php if (!eregi('^[0-9a-f]{6}$', $htmlcolor)) die ("bad color"); ?>

« previous php.notes (#133961) next »