Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 28th, 2005, 3:32 PM   #1
cloud-
Hobbyist Programmer
 
Join Date: Jan 2005
Posts: 110
Rep Power: 4 cloud- is on a distinguished road
normal colors to rgb (in separate variables)

hi,
im having a problem at the moment.

i have a function that returns a color value
but not in rgb.
so i can change the backcolor of my picturebox
but i have slider bars (3 for r,g,b)
so i need to have 3 separate variables
for red, green and blue

so i can use them separately and use the color like:
Rgb(redvar, greenvar, bluevar)
then i will be able to use my sliders ^^
like
slider1.value = redvar
slider2.value = greenvar
slider3.value = bluevar



please help me out with this
its the only thing i need to finish my program now

thanks
cloud- is offline   Reply With Quote
Old Jan 28th, 2005, 5:18 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
I assume what you're after is a "reverse-RGB" function.
Whilst the maths may be more complex than the clearer method of "mid"ing a HEX value, it's the most efficient.

Public Type RGBColour
    R As Byte
    G As Byte
    B As Byte
End Type

Public Function UnRGB(ByVal Color As Long) As RGBColour
UnRGB.R = Color Mod 256
Color = (Color - UnRGB.R) / 256
UnRGB.G = Color Mod 256
Color = (Color - UnRGB.G) / 256
UnRGB.B = Color Mod 256
End Function

So UnRGB(RGB(30,40,50)).R would = 30 and so on
Rory is offline   Reply With Quote
Old Jan 29th, 2005, 10:48 AM   #3
cloud-
Hobbyist Programmer
 
Join Date: Jan 2005
Posts: 110
Rep Power: 4 cloud- is on a distinguished road
no
sorry i should of made it clearer
i meant i need the ordiary color to be returned in rgb
i like how you made it so id be able to type UnRGB(RGB(30,40,50)).R

it would be cool if you could make one like GetRGB(number).R
and so on.

thanks alot
cloud- is offline   Reply With Quote
Old Jan 29th, 2005, 12:54 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
It still works - try it.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 29th, 2005, 1:47 PM   #5
cloud-
Hobbyist Programmer
 
Join Date: Jan 2005
Posts: 110
Rep Power: 4 cloud- is on a distinguished road
ahh so it does
guess i should have tried it first.
thanks alot both of you
cloud- is offline   Reply With Quote
Old Feb 1st, 2005, 3:23 AM   #6
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Glad to have been of help!
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC