note 57536 added to function.imagecolorallocate

From: Date: Thu, 06 Oct 2005 19:05:20 +0000
Subject: note 57536 added to function.imagecolorallocate
Groups: php.notes 
Request: Send a blank email to php-notes+get-96524@lists.php.net to get a copy of this message
Here's a very simple and very effective code to change a HEX color to RGB. ------------------------- function HEX2RGB($color){ $color_array = array(); $hex_color = strtoupper($color); for($i = 0; $i < 6; $i++){ $hex = substr($hex_color,$i,1); switch($hex){ case "A": $num = 10; break; case "B": $num = 11; break; case "C": $num = 12; break; case "D": $num = 13; break; case "E": $num = 14; break; case "F": $num = 15; break; default: $num = $hex; break; } array_push($color_array,$num); } $R = (($color_array[0] * 16) + $color_array[1]); $G = (($color_array[2] * 16) + $color_array[3]); $B = (($color_array[4] * 16) + $color_array[5]); return array($R,$G,$B); unset($color_array,$hex,$R,$G,$B); } ------------------------- ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57536 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57536&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57536&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57536&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57536&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57536&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57536&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57536&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57536&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#96524) next »