Need Color Conversion Function

This forum is for eXpress++ general support.
Message
Author
User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Need Color Conversion Function

#1 Post by unixkd »

Hi All

Anybody with a function to convert Xbase++ color code to HEX such as $00FFFFDC

Thanks

Joe

User avatar
Auge_Ohr
Posts: 1406
Joined: Wed Feb 24, 2010 3:44 pm

Re: Need Color Conversion Function

#2 Post 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
greetings by OHR
Jimmy

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Need Color Conversion Function

#3 Post 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.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Need Color Conversion Function

#4 Post by unixkd »

What I need is RGB to HTML color code conversion like { 0, 127, 127 } to something like $00FFFFDC

Thanks.

User avatar
Auge_Ohr
Posts: 1406
Joined: Wed Feb 24, 2010 3:44 pm

Re: Need Color Conversion Function

#5 Post 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
greetings by OHR
Jimmy

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Need Color Conversion Function

#6 Post by skiman »

Did you pass the array to that function? That won't work, you have to pass the separate values.
Best regards,

Chris.
www.aboservice.be

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Need Color Conversion Function

#7 Post 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.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Need Color Conversion Function

#8 Post by unixkd »

Hi Jimmy

I downloaded the latest ot4xb.dll but no ot4xb.lib only ot4xb_cpp.lib

Thanks

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Need Color Conversion Function

#9 Post by rdonnay »

Try DC_XbpToHtmlColor( <aColor> ) where <aColor> is an array of 3 RGB values.
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Need Color Conversion Function

#10 Post 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

Post Reply