• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Other✓] Converting RGB to GBA colours

3,830
Posts
14
Years
  • Age 27
  • OH
  • Seen Feb 26, 2024
So a GBA color is stored in a 16-bit unsigned integer, with the first 15 bits being dedicated to storing color information (5 bits for red, green, and blue). This is called, obviously, 15-bit RGB.

To get an RGB color to a GBA color, just use this:
Code:
gba_color = (((red >> 3) & 31) | (((green >> 3) & 31) << 5) | (((blue >> 3) & 31) << 10))

To go from GBA to RGB, use this:
Code:
red = (gba_color & 31) << 3
green = ((gba_color >> 5) & 31) << 3
blue = ((gba_color >> 10) & 31) << 3

Hope that helps! :)
 
Last edited:

xGal

Mhm
241
Posts
12
Years
So a GBA color is stored in a 16-bit unsigned integer, with the first 15 bits being dedicated to storing color information (5 bits for red, green, and blue). This is called, obviously, 15-bit RGB.

To get an RGB color to a GBA color, just use this:
Code:
gba_color = (((red >> 3) & 31) | (((green >> 3) & 31) << 5) | (((blue >> 3) & 31) << 10))

To go from GBA to RGB, use this:
Code:
red = (gba_color & 31) << 3
green = ((gba_color >> 5) & 31) << 3
blue = ((gba_color >> 10) & 31) << 3

Hope that helps! :)

Haha I didn`t know you know that. If I knew you know that I would ask you before ^^

That is exactly what I was looking for.
 
Back
Top