Page 1 of 2
Need Color Conversion Function
Posted: Wed Sep 27, 2017 2:29 pm
by unixkd
Hi All
Anybody with a function to convert Xbase++ color code to HEX such as $00FFFFDC
Thanks
Joe
Re: Need Color Conversion Function
Posted: Wed Sep 27, 2017 3:11 pm
by Auge_Ohr
unixkd wrote:Anybody with a function to convert Xbase++ color code to HEX such as $00FFFFDC
you can use RGB Value and cByte2Hex() (ot4xb) or StrToHex() (Tools)
Code: Select all
FUNCTION Color2Hex(xValue)
LOCAL cHex := "0x"
LOCAL aColor := {0,0,0}
DO CASE
CASE VALTYPE(xValue) = "A"
cHex += cByte2Hex(xValue[3])+;
cByte2Hex(xValue[2])+;
cByte2Hex(xValue[1])
CASE VALTYPE(xValue) = "N"
aColor := GraGetRGBIntensity(xValue)
IF aColor <> NIL
cHex += cByte2Hex(aColor[3])+;
cByte2Hex(aColor[2])+;
cByte2Hex(aColor[1])
ENDIF
ENDCASE
RETURN cHex
Re: Need Color Conversion Function
Posted: Wed Sep 27, 2017 3:49 pm
by unixkd
Hi Jimmy
I used StrToHex() and passed { 0, 127, 127 } which is dark cyan it returned 0x any thing value returned 0x
Thanks.
Re: Need Color Conversion Function
Posted: Wed Sep 27, 2017 4:05 pm
by unixkd
What I need is RGB to HTML color code conversion like { 0, 127, 127 } to something like $00FFFFDC
Thanks.
Re: Need Color Conversion Function
Posted: Wed Sep 27, 2017 5:11 pm
by Auge_Ohr
unixkd wrote:I used StrToHex() and passed { 0, 127, 127 } which is dark cyan it returned 0x any thing value returned 0x
have not try StrToHex() (Tools) but it work for me with cByte2Hex() (ot4xb) as i show i Code above.
these HEX Color are for Windows Controls ... not sure about HTML Color
Re: Need Color Conversion Function
Posted: Thu Sep 28, 2017 1:03 am
by skiman
Did you pass the array to that function? That won't work, you have to pass the separate values.
Re: Need Color Conversion Function
Posted: Thu Sep 28, 2017 1:26 pm
by unixkd
skiman wrote:Did you pass the array to that function? That won't work, you have to pass the separate values.
How ??
Look at the function properly, it expects an array as para.
Thanks.
Re: Need Color Conversion Function
Posted: Thu Sep 28, 2017 3:01 pm
by unixkd
Hi Jimmy
I downloaded the latest ot4xb.dll but no ot4xb.lib only ot4xb_cpp.lib
Thanks
Re: Need Color Conversion Function
Posted: Thu Sep 28, 2017 3:18 pm
by rdonnay
Try DC_XbpToHtmlColor( <aColor> ) where <aColor> is an array of 3 RGB values.
Re: Need Color Conversion Function
Posted: Thu Sep 28, 2017 3:46 pm
by unixkd
Hi Roger
DC_XbpToHtmlColor() only work for certain pre-defined colors returned by _NumColorToHtmlColor(aColor) in _dchtml.prg. I need a generic function that will work for ANY RGB colors.
Thanks.
Joe