![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#2 |
|
Expert Programmer
|
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 FunctionSo UnRGB(RGB(30,40,50)).R would = 30 and so on |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
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 ![]() |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
It still works - try it.
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
ahh so it does
guess i should have tried it first. ![]() thanks alot both of you |
|
|
|
|
|
#6 |
|
Expert Programmer
|
Glad to have been of help!
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|