forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Hex back to RGB?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Tue Aug 13, 2002 10:29 pm    Post subject: Hex back to RGB? Reply with quote

Ok, I know how to take RGB and get to HEX with it, but for the life
of me, I can't figure out how to reverse it back to RGB.....

Anyone have any idea's or clue's for me on this one??


Thanks in advance,
-Garrett


Last edited by Garrett on Wed Aug 14, 2002 6:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Tue Aug 13, 2002 10:37 pm    Post subject: Reply with quote

Take each RGB hex value (individually), and do this:

@sum($%%value, 0)

This converts it back to decimal. Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361


Last edited by Mac on Tue Aug 13, 2002 10:39 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Tue Aug 13, 2002 10:37 pm    Post subject: Reply with quote

Depending on what you're trying to do, the following code will show useful things:

Code:

  %%vdscolor = @sum($00123456,0)
  %%hex = @hex(%%vdscolor,8)
  %%blue = @sum($@substr(%%hex,3,4),0)
  %%green = @sum($@substr(%%hex,5,6),0)
  %%red = @sum($@substr(%%hex,7,8),0)
  info VDS color: %%vdscolor@cr()Hex color: %%hex@cr()Red: %%red@cr()Green: %%green@cr()Blue: %%blue

Back to top
View user's profile Send private message Send e-mail Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Wed Aug 14, 2002 6:39 pm    Post subject: Reply with quote

Mac, Tommy, Thanks a bunch. Smile

-Garrett
Back to top
View user's profile Send private message
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Fri Aug 16, 2002 12:16 pm    Post subject: RGB to HEX Reply with quote

Can someone tell me how to convert a color value from the registry (ex. 0 78 152) to HEX? (does VDS 3.51 understand HEX?)

Erik
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Aug 16, 2002 5:17 pm    Post subject: Reply with quote

Yes, you can use the @hex() function.

While @format() will limit numbers to the length supplied, it
will NOT add leading zeros if the string is shorter, so you
must modify string length to get 2 digit RGB hex values.
Code:

%%num1 = 0
if @greater(2, @len(@format(@hex(%%num1), 2.0)))
   %%num1 = "0"@format(@hex(%%num1), 2.0)
else
   %%num1 = @format(@hex(%%num1), 2.0)
end

%%num2 = 78
if @greater(2, @len(@format(@hex(%%num2), 2.0)))
   %%num2 = "0"@format(@hex(%%num2), 2.0)
else
   %%num2 = @format(@hex(%%num2), 2.0)
end

%%num3 = 152
if @greater(2, @len(@format(@hex(%%num3), 2.0)))
   %%num3 = "0"@format(@hex(%%num3), 2.0)
else
   %%num3 = @format(@hex(%%num3), 2.0)
end

INFO  %%num1%%num2%%num3

Cheers, Mac

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Fri Aug 16, 2002 7:17 pm    Post subject: RGB to HEX Reply with quote

But how can I divide a value in 3 numbers? bacause if I take it out of the registry (%%BackgroundColor = @REGREAD(CURUSER,Control Panel\Colors,Background) I get 0 78 152. Is it possible to divide that into 3 numbers?

Erik
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Protected
Valued Contributor
Valued Contributor


Joined: 02 Jan 2001
Posts: 228
Location: Portugal

PostPosted: Fri Aug 16, 2002 7:23 pm    Post subject: Reply with quote

Use the PARSE command. If your 0 78 152 is in %%NUMBER, it would look like:

OPTION FIELDSEP," "
PARSE "%A;%B;%C",%%NUMBER
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
moke
Contributor
Contributor


Joined: 02 Jan 2002
Posts: 162

PostPosted: Fri Aug 16, 2002 7:24 pm    Post subject: Reply with quote

Could you parse it using @chr(32) as the field sep?
Back to top
View user's profile Send private message Send e-mail
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Fri Aug 16, 2002 7:25 pm    Post subject: RGB -> HEX Reply with quote

OK, thnx.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Fri Aug 16, 2002 7:44 pm    Post subject: RGB to HEX Reply with quote

another question:

Can I set a style to a color with DIALOG SET,STYLE1,BLACK ? (I downloaded a color picker a while ago, but I can't find it anymore)

Erik
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Aug 16, 2002 10:09 pm    Post subject: Reply with quote

No.

Styles are not treated like other elements in VDS. You must
add all styles you expect to use when you create the dialog.

BTW, here's a VDS Color Picker for HTML compatible colors:

http://www.vdsworld.com/forum/viewtopic.php?t=384

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Tsunami1988
Contributor
Contributor


Joined: 15 Aug 2002
Posts: 70
Location: The Netherlands

PostPosted: Sat Aug 17, 2002 8:56 am    Post subject: RGB -> HEX Reply with quote

OK, thanks again.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group