Hi leute.
Wie kann ich mit PHP einen farbwert im hexadezimal system in RGB werte umrechnen?
Danke, stefan
Wie kann ich mit PHP einen farbwert im hexadezimal system in RGB werte umrechnen?
Danke, stefan
<?php
error_reporting(E_ALL);
function HEXtoRGB ($RGB) {
$R = hexdec(substr($RGB,1,2));
$G = hexdec(substr($RGB,3,2));
$B = hexdec(substr($RGB,5,2));
return $R.','.$G.','.$B;
}
echo HEXtoRGB('#FF0000');
?>
error_reporting(E_ALL); function HEXtoRGB ($RGB) { $R = hexdec(substr($RGB,1,2)); $G = hexdec(substr($RGB,3,2)); $B = hexdec(substr($RGB,5,2)); return $R.','.$G.','.$B; } $color = HEXtoRGB('#FF0000');
$fcolor = imagecolorallocate($image, 255, 255,255);
<?php
$h = '0f1007';
$rgb = array_map('hexdec', str_split($h, 2));
print_r($rgb_dec);
?>
<?php
function HEXtoRGB ($RGB) {
$RGB = trim( $RGB, ' |#');
$R = hexdec(substr($RGB,1,2));
$G = hexdec(substr($RGB,3,2));
$B = hexdec(substr($RGB,5,2));
return array($R,$G,$B);
?>
<?php $h = '0f1007'; $rgb = array_map('hexdec', str_split($h, 2)); print_r($rgb_dec); ?>
$rgb[0];
<?php function HEXtoRGB ($RGB) { $RGB = trim( $RGB, ' |#'); $R = hexdec(substr($RGB,1,2)); $G = hexdec(substr($RGB,3,2)); $B = hexdec(substr($RGB,5,2)); return array($R,$G,$B); ?>
<?php
$h = '0f1007';
list($r, $g, $b) = array_map('hexdec', str_split($h, 2));
$fcolor = imagecolorallocate($image, $r, $g, $b);
?>
Kommentar