note 39645 deleted from function.imagecolorallocatealpha by didou

From: Date: Fri, 06 Feb 2004 10:10:12 +0000
Subject: note 39645 deleted from function.imagecolorallocatealpha by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-64717@lists.php.net to get a copy of this message
Note Submitter: htflumpy@hotmail.com ---- I thought it might be easier if you could simply create a color by using it's hexadecimal value. So i created a function which works excactly as imagecolorallocatealpha except you can give the hexadecimal color as parameter. <? function ImageHexColorAllocateAlpha($im, $color) { $b = $color % 256; $color = floor($color / 256); $g = $color % 256; $color = floor($color / 256); $r = $color % 256; $color = floor($color / 256); $a = $color; return ImageColorAllocateAlpha($im,$r,$g,$b,$a); } ?> enter the hexadecimal value as followed: alpha,red,green,blue 0x5000FF00 = would produce a green color with 50 alpha: 50 alpha 00 red FF green 00 blue if you do not want alpha you may leave the alpha value away so 0x0000FF would be blue. Example to add red to the color palette: <? $red = ImageHexColorAllocateAlpha($MyImage,0x00FF0000); ?> Hope this helps someone, Fossalta

« previous php.notes (#64717) next »