RGB Problem

Just starting out? Need help? Post your questions and find answers here.
<David.C#S4701L>
New User
New User
Posts: 4
Joined: Thu Sep 20, 2007 1:37 pm
Location: On your computer screen!

RGB Problem

Post by <David.C#S4701L> »

According to my friend (and http://www.javascripter.net/faq/hextorgb.htm )

Code: Select all

R = Red($413eba)
G = Green($413eba)
B = Blue($413eba)

MessageRequester("", Str(R)+" "+Str(G)+" "+Str(B))
and

Code: Select all

R = 10
G = 20
B = 30

MessageRequester("", Hex(RGB(R,G,B)))
Is actually returning the combination BGR (Blue, green, red) instead of RGB. (red green blue)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

What is the problem here? Come on ! all is correct.
No bug. Don't scare to people :roll:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
..::Origin::..
Enthusiast
Enthusiast
Posts: 125
Joined: Sat Jun 17, 2006 3:15 pm

Post by ..::Origin::.. »

Code: Select all

R = Red($413eba)
G = Green($413eba)
B = Blue($413eba)

MessageRequester("", Str(R)+" "+Str(G)+" "+Str(B))
It Is done as BBGGRR, I do not think the functions, Red() : Blue() : Green; were supposed to be used with this.

A quick modification would be to just do:

Code: Select all

R = Blue($413eba)
G = Green($413eba)
B = Red($413eba)

MessageRequester("", Str(R)+" "+Str(G)+" "+Str(B))
As much as It doesn't look right, It works fine.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

specifying a color numerically is always done with Red as the lower digit.

$FF is full red, right ?

So $0000FF is still full red... And you got the point.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

People tend to look at $0000FF like this:

Code: Select all

$0000FF
 RRGGBB
And they think FF relates to BB, which is wrong (as Fred pointed out).
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Blame intel for this behaviour. All x86 based CPU's store 16bit and 24bit and 64bit values etc. "in reverse".

Search around this forum though, both I and others have done a few small snippets of code and examples on how to invert/flip the RGB numbers.

@Fred, maybe a flip value command could be added to a future PB? In ASM it's like a single operator at least for 32bit values.
User avatar
Dreamland Fantasy
Enthusiast
Enthusiast
Posts: 335
Joined: Fri Jun 11, 2004 9:35 pm
Location: Glasgow, UK
Contact:

Post by Dreamland Fantasy »

Post Reply