AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hex to RGB

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
EveOnline001



Joined: 23 Mar 2009
Posts: 27

PostPosted: Tue Mar 24, 2009 8:33 am    Post subject: Hex to RGB Reply with quote

How to convert 0x949494 to RGB?
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Mar 24, 2009 8:38 am    Post subject: Reply with quote

Rolling Eyes Your (other) request about PixelGetColor dissapeared while I answered it. Mad
And now you request a conversion without telling what you need it for. Great. If you read the manual about PixelGetColor you'd find this ...
Quote:
RGB: Retrieves the color in RGB vs. BGR format. In other words, the red and the blue components are swapped. This is useful for retrieving colors compatible with WinSet, Gui, Progress, and SplashImage.
Any reason why you wanna do a conversion while its already a feature of the standard command? RTFM.
Back to top
EveOnline001



Joined: 23 Mar 2009
Posts: 27

PostPosted: Tue Mar 24, 2009 9:24 am    Post subject: Reply with quote

PixelGetColor just replaces the locations, but it's still a HEX code.

I need 255, 255, 255 style.

What was your reply to my other thread? Razz

I need it so I can perform some calculations. When R > B, then I know the color is an orange. When R < B, then I know the color is a blue. When (R>190 && B>190) I know the color is a white. When (R<10 && B < 10) I know the color is a black.

I have to use it to determine when this capacity bar is full/empty.

Empty is blue:



Full is orange:




I cannot use exact HEX color codes because the lighting in the game changes the colors. So I have to compare to figure out if the color is an orange or a blue. And I cannot do that with HEX codes because you can't compare letters.
Back to top
View user's profile Send private message
BoBoł
Guest





PostPosted: Tue Mar 24, 2009 10:01 am    Post subject: Reply with quote

So it looks like the AHK manual will be your new friend! It tells you (once you started to search for it) that SetFormat will do that conversion. That's great news, right! Good luck, and please hesitate to ask for every single bit & piece. Very Happy
Back to top
animeaime



Joined: 04 Nov 2008
Posts: 1045

PostPosted: Tue Mar 24, 2009 11:41 am    Post subject: Reply with quote

This function will "parse" the color and split it into its Red, Green, and Blue parts - I presume you wanted each separate, right? Note, this works for both hex and decimal numbers (uses bit-wise math).

If the color is in RGB form, use SplitRGBColor. If the color is in BGR form, use SplitBGRColor.

Code:
;form 0xRRGGBB
color := 0x010203

SplitRGBColor(color, Red, Green, Blue)

MsgBox, % "RGB " Color " split is:`n"
    . "Red: " Red . "`n"
    . "Green: " Green . "`n"
    . "Blue: " Blue . "`n"
   
;form 0xBBGGRR
color := 0x010203

SplitBGRColor(color, Red, Green, Blue)

MsgBox, % "BGR " Color " split is:`n"
    . "Red: " Red . "`n"
    . "Green: " Green . "`n"
    . "Blue: " Blue . "`n"

;color MUST be in RGB form
;this function splits the color into its Red, Green, and Blue parts
SplitRGBColor(RGBColor, ByRef Red, ByRef Green, ByRef Blue)
{
    Red := RGBColor >> 16 & 0xFF
    Green := RGBColor >> 8 & 0xFF
    Blue := RGBColor & 0xFF
}

;color MUST be in BGR form
;this function splits the color into its Red, Green, and Blue parts
SplitBGRColor(BGRColor, ByRef Red, ByRef Green, ByRef Blue)
{
    Red := BGRColor & 0xFF
    Green := BGRColor >> 8 & 0xFF
    Blue := BGRColor >> 16 & 0xFF
}

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.
Back to top
View user's profile Send private message Send e-mail
EveOnline001



Joined: 23 Mar 2009
Posts: 27

PostPosted: Tue Mar 24, 2009 6:25 pm    Post subject: Reply with quote

You are amazing. Thank you for the help Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group