note 40497 modified in function.imagecolorallocate by danbrown
| From: | danbrown@php.net | Date: | Fri, 24 Apr 2009 12:52:19 +0000 |
| Subject: | note 40497 modified in function.imagecolorallocate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153674@lists.php.net to get a copy of this message | ||
this might help someone, how to allocate an color from an html color-definition:
<?php
$fg = "#ff0080";
$red = 100;
$green = 100;
$blue = 100;
if( eregi( "[#]?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})", $fg, $ret ) )
{
$red = hexdec( $ret[1] );
$green = hexdec( $ret[2] );
$blue = hexdec( $ret[3] );
}
$text_color = ImageColorAllocate( $img1, $red, $green, $blue );
?>
--was--
this might help someone, how to allocate an color from an html color-definition:
$fg = "#ff0080";
$red = 100;
$green = 100;
$blue = 100;
if( eregi( "[#]?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})", $fg, $ret ) )
{
$red = hexdec( $ret[1] );
$green = hexdec( $ret[2] );
$blue = hexdec( $ret[3] );
}
$text_color = ImageColorAllocate( $img1, $red, $green, $blue );
http://php.net/manual/en/function.imagecolorallocate.php