# Question - CodeWhy are hex colours #BBGGRR instead of #RRGGBB?

B

#### Big_Macca_101

##### Guest
Just curious as to why GMS uses hexadecimal colours in the format of Blue/Green/Red rather than Red/Green/Blue like most other programs and languages use?

Its just a bit confusing to me and to other's I would imagine.

#### nacho_chicken

##### Member
Because colors are stored in little endian. draw_set_color() takes only one argument, which is color. You'll notice that make_color_rgb() is in the standard format, and this outputs a little endian color value.

As far as what "little endian" means, that's a complicated subject and a totally different question. If you want to learn a bit more, this is a good place to start.

B

#### Big_Macca_101

##### Guest
Because colors are stored in little endian. draw_set_color() takes only one argument, which is color. You'll notice that make_color_rgb() is in the standard format, and this outputs a little endian color value.

As far as what "little endian" means, that's a complicated subject and a totally different question. If you want to learn a bit more, this is a good place to start.
Awesome thankyou, I'll look into this, might just write a script to convert an RGB hex format to GMS colour.

#### gnysek

##### Member
It's a leftover from Delphi, which used "little endian" format.

#### Juju

##### Member
BGR is used elsewhere as well, though I forget where off hand.

#### nacho_chicken

##### Member
EDIT: Use gnysek's script below instead.

I was bored and also wanted to write my colors as RGB so I just wrote up this simple RGB to BGR script. Feel free to use it.

Code:
``````///convert_color_endianness(val)
//Converts a color from RGB to the little endian BGR and vice versa
var rgb = argument[0],
bgr = 0,   //Output
bsh = \$10; //Number of bits to shift

bgr = (rgb & \$FF) << bsh;      //Blue
bgr += (rgb & \$FF00);          //Green
bgr += (rgb & \$FF0000) >> bsh; //Red

return bgr;``````
Also feel free to change the name. It's pretty long and I didn't put much thought into it.

Last edited:

#### gnysek

##### Member
I was bored and also wanted to write my colors as RGB so I just wrote up this simple RGB to BGR script. Feel free to use it.

Code:
``````///convert_color_endianness(val)
//Converts a color from RGB to the little endian BGR and vice versa
var rgb = argument[0],
bgr = 0,   //Output
bsh = \$10; //Number of bits to shift

bgr = (rgb & \$FF) << bsh;      //Blue
bgr += (rgb & \$FF00);          //Green
bgr += (rgb & \$FF0000) >> bsh; //Red

return bgr;``````
Also feel free to change the name. It's pretty long and I didn't put much thought into it.

Code:
``````/// @desc rgb_to_bgr - converts RGB int/hex to BGR real
/// @param rgb_color {real} example: \$00BBFF or 48127

return (argument0 & \$FF) << 16 | (argument0 & \$FF00) | (argument0 & \$FF0000) >> 16;``````
I love one liners <3 !

#### nacho_chicken

##### Member
Code:
``````/// @desc rgb_to_bgr - converts RGB int/hex to BGR real
/// @param rgb_color {real} example: \$00BBFF or 48127

return (argument0 & \$FF) << 16 | (argument0 & \$FF00) | (argument0 & \$FF0000) >> 16;``````
I love one liners <3 !
I knew I was forgetting something. I even normally do that with 16-bit ints. It's too late for me to code, haha.

#### Storyteller

##### Member
there really seems to be no reason to keep things this way. being compatible with other languages, libraries and standards of practice is a good thing. all the oddities that remain for backwards compatibility are part of what keeps GM from reaching its potential. there is no good reason to keep this non-standard practice.