Re: Convert a grayscale value to a #RRGGBB hex value

From: Date: Mon, 24 Jun 2002 17:04:13 +0000
Subject: Re: Convert a grayscale value to a #RRGGBB hex value
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-103623@lists.php.net to get a copy of this message
If you know its grayscale... function GrayScaleToHex( $val ) { $norm = $val * 2.55 + $val/100; $hex = sprintf("%02X", $norm); return '#' . $hex . $hex . $hex; } Should get you close enough. Matt René fournier wrote:
Anyone know how I might convert a grayscale value, from between 0 to 100, to hex, such that 0 (black) would be returned as #000000, and 100 (white) as #FFFFFF? For example... function grayscaletohex ($val) {
    $hex = $val ... [ a simple operation ]
    return $hex;
    }
Thanks. ...Rene --- René Fournier, rene@smartslitters.com Toll-free +1.888.886.2754 Tel +1.403.291.3601 Fax +1.403.250.5228 www.smartslitters.com SmartSlitters International #33, 1339 - 40th Ave NE Calgary AB T2E 8N6 Canada


« previous php.general (#103623) next »