note 90731 added to function.imagecolorallocate
| From: | shinesoldier at gmail dot com | Date: | Wed, 06 May 2009 23:16:24 +0000 |
| Subject: | note 90731 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154295@lists.php.net to get a copy of this message | ||
Here's a very simple function that basically does the same as imagecolorallocate(), only
without needing an image resource to work.
<?php
function createcolor($r, $g, $b) {
return hexdec(str_pad(dechex($r), 2, 0, STR_PAD_LEFT).str_pad(dechex($g), 2, 0,
STR_PAD_LEFT).str_pad(dechex($b), 2, 0, STR_PAD_LEFT));
}
/* As said earlier, this function does the exact same thing as imagecolorallocate(), without needing
an image resource. This means that the following two blocks of code result in the exact same thing:
*/
//Block 1
$color = colorcreate(105, 199, 204);
//Block 2
$img = imagecreatetruecolor(100, 100); //the arguments here don't really matter
$color = imagecolorallocate($img, 105, 199, 204);
imagedestroy($img);
?>
----
Server IP: 64.71.164.2
Probable Submitter: 195.240.61.15
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php
Edit -- https://master.php.net/note/edit/90731
Del: integrated -- https://master.php.net/note/delete/90731/integrated
Del: useless -- https://master.php.net/note/delete/90731/useless
Del: bad code -- https://master.php.net/note/delete/90731/bad+code
Del: spam -- https://master.php.net/note/delete/90731/spam
Del: non-english -- https://master.php.net/note/delete/90731/non-english
Del: in docs -- https://master.php.net/note/delete/90731/in+docs
Del: other reasons-- https://master.php.net/note/delete/90731
Reject -- https://master.php.net/note/reject/90731
Search -- https://master.php.net/manage/user-notes.php