|
#1
|
||||
|
||||
|
Hex 2 R,g,b
Does anyone know a formula for converting a Hex value or a Decimal value for a color, into the correct R,G,B color value?
.
__________________
Add-ons for AMS. Toolbar Buttons Galore, System Animations, the Window Construction Kit, and more. Visit Acme-Tek |
|
#2
|
||||
|
||||
|
I believe the script "rgb.lua" found in your AMS script gallery has a function to do that.
|
|
#3
|
||||
|
||||
|
Thanks Corey, that Lua script is similar to what I’m after, but not quite. It will let me go from R,G,B to Decimal, or from R,G,B to Hex, but I want to go in the other direction. I want to change Hex to R,G,B and/or Decimal to R,G,B
.
__________________
Add-ons for AMS. Toolbar Buttons Galore, System Animations, the Window Construction Kit, and more. Visit Acme-Tek |
|
#4
|
|||
|
|||
|
You can use this to get HEX to RGB, then use the other RGB.LUA to go from there
Code:
function Hex2RGB(sHexString)
if String.Length(sHexString) ~= 6 then
return 0,0,0
else
red = String.Left(sHexString,2)
green = String.Mid(sHexString,3,2)
blue = String.Right(sHexString,2)
red = tonumber(red, 16).."";
green = tonumber(green, 16).."";
blue = tonumber(blue, 16).."";
return red, green, blue
end
end
red, green, blue = Hex2RGB("FFCCFF")
Dialog.Message("", red..", "..green..", "..blue)
|
|
#6
|
|||
|
|||
|
one thing on that is that the LUA function returns a number (thanks Tig)
If you want the returned values to be numbers, remove the .."" in the function. Also as an after thought, you might want to return -1, -1, -1 if the Hex string isn't the correct length so you can test if the function was successful. Code:
function Hex2RGB(sHexString)
if String.Length(sHexString) ~= 6 then
return -1, -1, -1
else
red = String.Left(sHexString,2)
green = String.Mid(sHexString,3,2)
blue = String.Right(sHexString,2)
red = tonumber(red, 16);
green = tonumber(green, 16);
blue = tonumber(blue, 16);
return red, green, blue
end
end
red, green, blue = Hex2RGB("FFCCFF")
if red ~= -1 then
Dialog.Message("", red..", "..green..", "..blue)
else
Dialog.Message("","Function failed")
end
|
|
#7
|
||||
|
||||
|
Wow! Thanks again Worm, your kindness is amazing.
I had looked through the forums before I posted, and I noticed functions that convert in other directions, but I couldn’t find this one, the one I most needed. Your help on this is very much appreciated. .
__________________
Add-ons for AMS. Toolbar Buttons Galore, System Animations, the Window Construction Kit, and more. Visit Acme-Tek |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HEX to ASCII converter | SUF6NEWBIE | AutoPlay Media Studio 5.0 | 2 | 01-14-2005 06:14 PM |
| RGB to HEX | jwarrent | AutoPlay Media Studio 5.0 | 13 | 08-25-2004 05:49 PM |
| Program: Binary Hex and Decimal Converter | Protocol | AutoPlay Media Studio 5.0 Examples | 3 | 07-15-2004 01:11 PM |
| Converting hex value to decimal...can we do this in SF6?? | Martin_SBT | Setup Factory 6.0 | 5 | 02-06-2003 03:22 PM |
| Hex Code replacing | BaZZa101 | AutoPlay Media Studio 4.0 | 1 | 01-06-2003 12:21 PM |
All times are GMT -6. The time now is 07:37 AM.








Linear Mode

