Jump to content

Hex To RGB Convertor


Recommended Posts

Hello, I'm Looking for a Hex to RGB Coverter Code Snipet for my AutoIt App,I Tried Looking online and searching the forums but no luck. My Reason behind this is because im having too programs comunnicate to each other by TCP Networking on the same computer. Anyway AutoIt is going to send different Hex values rapidly to another program, thing is that program cannot read Hex for the command im using nor does it has a convertor.. does anyone have a snipet of code that I can use? thanks

Link to comment
Share on other sites

Thanks but the other program i am using can only convert decimal to hex and vis virsa, i will hope to use this another time thanks, howerver i did find a chart on the hex values which i might be able to use to create my own program (http://webdesign.about.com/od/colorcharts/l/bl_rgb2hex.htm)
Link to comment
Share on other sites

Thanks but the other program i am using can only convert decimal to hex and vis virsa, i will hope to use this another time thanks, howerver i did find a chart on the hex values which i might be able to use to create my own program (http://webdesign.about.com/od/colorcharts/l/bl_rgb2hex.htm)

Humm...unless I'm not getting what your asking for, I was assuming you would use this way cool function from the script I referenced within your own app.

; #FUNCTION# ==============================================================
; Function Name..: _HexToDec ( "expression" )
; Description ...: Returns decimal expression of a hexadecimal string.
; Parameters ....: expression   - String representation of a hexadecimal expression to be converted to decimal.
; Return values .: Success      - Returns decimal expression of a hexadecimal string.
;                  Failure      - Returns "" (blank string) and sets @error to 1 if string is not hexadecimal type.
; Author ........: jennico (jennicoattminusonlinedotde)
; Remarks .......: working input format: "FFFF" or "0xFFFF" (string format), do NOT pass 0xFFFF without quotation marks (number format).
;               current AutoIt Dec() limitation: 0x7FFFFFFF (2147483647).
; Related .......: Hex(), Dec(), _DecToHex()
; =======================================================================
Func _HexToDecimal($hx_hex)
    If StringLeft($hx_hex, 2) = "0x" Then $hx_hex = StringMid($hx_hex, 3)
    If StringIsXDigit($hx_hex) = 0 Then
        SetError(1)
        MsgBox(0,"Error","Wrong input, try again ...")
        Return ""
    EndIf
    Local $ret="", $hx_count=0, $hx_array = StringSplit($hx_hex, ""), $Ii, $hx_tmp
    For $Ii = $hx_array[0] To 1 Step -1
        $hx_tmp = StringInStr($HX_REF, $hx_array[$Ii]) - 1
        $ret += $hx_tmp * 16 ^ $hx_count
        $hx_count += 1
    Next
    Return $ret
EndFunc  ;==>_HexToDec()

Please clarify your request if I appear to have rode the short bus today.

-Mike

Link to comment
Share on other sites

  • Moderators

DarkDragon,

Hex to RGB Coverter

What exactly do you want to convert to what? :blink:

RGB can be expressed as both a Hex and a Decimal digit - Hex/Dec will do the conversion automatically.

If you want the individual RGB elements of colour value, you can use _ColorGetBlue/Green/Red on either format. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Im Sorry for not being as clear as i can, my second program which is going to recieve the Hex data from autoit cannot read that hex data becuase it is using a command that caan ONLY read argb(alpha,red,green,blue) {how nice of them i know},thats the reason why i need a piece of coded to convert the Hex or decimal values to an rgb value :blink:

Link to comment
Share on other sites

DarkDragon,

What exactly do you want to convert to what? :blink:

RGB can be expressed as both a Hex and a Decimal digit - Hex/Dec will do the conversion automatically.

If you want the individual RGB elements of colour value, you can use _ColorGetBlue/Green/Red on either format. ;)

M23

Thanks you thats all i needed however i didnt know that that command was there , ill be sure to use it

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...