Created
January 3, 2022 22:03
-
-
Save ClearlyKyle/8ff2185a06fd30af330ab07dc9f20a3c to your computer and use it in GitHub Desktop.
SDL_Colour to Uint32 for SDL_gfx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Uint32 SDL_Colour_To_Uint32(const SDL_Colour *col) | |
| { | |
| // Must be format AABBGGRR for gfx library | |
| return (Uint32)((col->a << 24) + (col->b << 16) + (col->g << 8) + (col->r << 0)); | |
| } | |
| SDL_Colour Uint32_To_SDL_Colour(const Uint32 colour) | |
| { | |
| SDL_Colour tmp; | |
| tmp.a = (colour >> 24) & 0xFF; | |
| tmp.b = (colour >> 16) & 0xFF; | |
| tmp.g = (colour >> 8) & 0xFF; | |
| tmp.r = colour & 0xFF; | |
| return tmp; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment