note 96799 added to function.imagecolorallocate
| From: | yettycz at gmail dot com | Date: | Tue, 16 Mar 2010 18:27:47 +0000 |
| Subject: | note 96799 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167101@lists.php.net to get a copy of this message | ||
Two useful functions for convert integer from imageCollorAllocate to RGB hex (FFFFFF eg.) and to
array of integers 0..255:
<?php
/**
* Convert color from imageColorAllocate() to hex in XXXXXX (eg. FFFFFF, 000000, FF0000)
*
* name: color2rgb
* author: Yetty
* @param $color value from imageColorAllocate()
* @return string; color in style XXXXXX (eg. FFFFFF, 000000, FF0000)
*/
function color2rgb($color) {
return str_pad(base_convert($color, 10, 16), 6, 0, STR_PAD_LEFT);
}
/**
* Convert color from hex in XXXXXX (eg. FFFFFF, 000000, FF0000) to array(R, G, B)
* of integers (0-255).
*
* name: rgb2array
* author: Yetty
* @param $color hex in XXXXXX (eg. FFFFFF, 000000, FF0000)
* @return string; array(R, G, B) of integers (0-255)
*/
function rgb2array($rgb) {
return array(
base_convert(substr($rgb, 0, 2), 16, 10),
base_convert(substr($rgb, 2, 2), 16, 10),
base_convert(substr($rgb, 4, 2), 16, 10),
);
}
?>
----
Server IP: 147.32.160.17
Probable Submitter: 94.74.221.242
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php
Edit -- https://master.php.net/note/edit/96799
Del: integrated -- https://master.php.net/note/delete/96799/integrated
Del: useless -- https://master.php.net/note/delete/96799/useless
Del: bad code -- https://master.php.net/note/delete/96799/bad+code
Del: spam -- https://master.php.net/note/delete/96799/spam
Del: non-english -- https://master.php.net/note/delete/96799/non-english
Del: in docs -- https://master.php.net/note/delete/96799/in+docs
Del: other reasons-- https://master.php.net/note/delete/96799
Reject -- https://master.php.net/note/reject/96799
Search -- https://master.php.net/manage/user-notes.php