- 1
- Posts
- 6
- Years
- Seen Apr 30, 2020
Hello, this is my first time at this forum. Sorry for the bad English, I'm not fluent. Well, I am wiriting a program in C# for edit a game of AGB, I've developed many tools: A Script Editor to edit text as a Notepad, an Item Editor to edit itens description and now I'm developing a Graphic Editor that needs a palet converter between GBA and RGB colors. I've looked a thread (Looks like I can't post links because I don't have 5 points or more)
But I really did not understand that ">>", "&" and "|". Can someone explain me?
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! :)
But I really did not understand that ">>", "&" and "|". Can someone explain me?