note 87349 added to function.imagecolordeallocate
| From: | janos at since78 dot net | Date: | Mon, 01 Dec 2008 15:59:12 +0000 |
| Subject: | note 87349 added to function.imagecolordeallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147486@lists.php.net to get a copy of this message | ||
converting HTML color (like #AAED43) to three RGB values ($r = 170, $g = 237, $b = 67)
<?php
function html2rgb($color)
{
if ($color[0] == '#')
$color = substr($color, 1);
if (strlen($color) == 6)
list($r, $g, $b) = array($color[0].$color[1],
$color[2].$color[3],
$color[4].$color[5]);
elseif (strlen($color) == 3)
list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
else
return false;
$r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
return array($r, $g, $b);
}
?>
converting RGB values to HTML color
<?php
function rgb2html($r, $g=-1, $b=-1)
{
if (is_array($r) && sizeof($r) == 3)
list($r, $g, $b) = $r;
$r = intval($r); $g = intval($g);
$b = intval($b);
$r = dechex($r<0?0:($r>255?255:$r));
$g = dechex($g<0?0:($g>255?255:$g));
$b = dechex($b<0?0:($b>255?255:$b));
$color = (strlen($r) < 2?'0':'').$r;
$color .= (strlen($g) < 2?'0':'').$g;
$color .= (strlen($b) < 2?'0':'').$b;
return '#'.$color;
}
?>
----
Server IP: 87.124.35.190
Probable Submitter: 82.110.252.130
----
Manual Page -- http://www.php.net/manual/en/function.imagecolordeallocate.php
Edit -- https://master.php.net/note/edit/87349
Del: integrated -- https://master.php.net/note/delete/87349/integrated
Del: useless -- https://master.php.net/note/delete/87349/useless
Del: bad code -- https://master.php.net/note/delete/87349/bad+code
Del: spam -- https://master.php.net/note/delete/87349/spam
Del: non-english -- https://master.php.net/note/delete/87349/non-english
Del: in docs -- https://master.php.net/note/delete/87349/in+docs
Del: other reasons-- https://master.php.net/note/delete/87349
Reject -- https://master.php.net/note/reject/87349
Search -- https://master.php.net/manage/user-notes.php