note 39645 added to function.imagecolorallocatealpha

From: Date: Thu, 05 Feb 2004 21:27:23 +0000
Subject: note 39645 added to function.imagecolorallocatealpha
Groups: php.notes 
Request: Send a blank email to php-notes+get-64701@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorallocatealpha.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39645 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39645&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39645&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64701) next »