It depends on how you're attempting to access / use the Data.
Remember that by default an AppGameKit Integer is a 32-bit Signed Variable., so if you're just doing "Normal" Mathematics with it... it'll behave as a value between 2,147,483,647 > 0 > -2,147,483,648
Unlike most Languages (like DBP for example) that uses an Unsigned 32-bit., thus it's a value between 0 > 4,294,967,295
Bitwise Mathematics however are exclusively unsigned by nature... because you're working with the Bits themselves, and those can only have 2 States (On / Off or 1 / 0)
This means these
// Remember that AGK uses ABGR instead of ARGB, but Memblocks use ARGB
Function ARGB( Red As Integer, Green As Integer, Blue As Integer, Alpha As Integer )
Local Output As Integer
Output = ( Blue || (Green << 8) || (Red << 16) || (Alpha << 24) )
EndFunction Output
Function RGB( Red As Integer, Green As Integer, Blue As Integer )
Local Output As Integer
Output = ARGB( Red, Green, Blue, 0xFF )
EndFunction Output
Function ABGR( Red As Integer, Green As Integer, Blue As Integer, Alpha As Integer )
Local Output As Integer
Output = ( Red || (Green << 8) || (Blue << 16) || (Alpha << 24) )
EndFunction Output
Function BGR( Red As Integer, Green As Integer, Blue As Integer )
Local Output As Integer
Output = ABGR( Red, Green, Blue, 0xFF )
EndFunction Output
Function ToAGKColor( Input As Integer )
Local Output As Integer
Output = ABGR( ((Input >> 16) && 0xFF), ((Input >> 8) && 0xFF), (Input && 0xFF), ((Input >> 24) && 0xFF) )
EndFunction Output
Function ToRGBColor( Input As Integer )
Local Output As Integer
Output = ARGB( (Input && 0xFF), ((Input >> 8) && 0xFF), ((Input >> 16) && 0xFF), ((Input >> 24) && 0xFF) )
EndFunction Output
Work perfectly... and as a note., these specifically convert between AppGameKit's ABGR and Dark BASIC Professional's ARGB Pixel Formats.
Oh and while this is AppGameKit "Code" so-to-speak., it'll work identically on Dark BASIC Professional.
Now while these don't actually "Return" the individual Alpha, Red, Green, Blue Terms... if you look at the "To" Functions, strictly speaking that's exactly what I'm going to basically Flip the Red and Blue Channels to each format.
So if you want the specific Colour from said format; then:
Function GetRedFromColor( Input As Integer )
Local Output As Integer
Output = Input >> 24 && 0xFF
EndFunction Output
Should return the correct 0-255 Value.
I mostly use these Functions because I prefer to use Hexidecimal Definitions for Colours... used for Browsers, Photoshop, Microsoft Paint, Maya, etc.
It's just easier to use with 0xRRGGBBAA (i.e. 0xFF0000FF = 100% Brightness Red), then I can use these Functions to convert it to the same Colour as AppGameKit would use.