API: moved functions to files to make it easier to import to other projects

This commit is contained in:
Andrew Haynes
2026-03-22 17:24:40 -04:00
parent 05a15d38af
commit 64cf77bbe3
11 changed files with 678 additions and 572 deletions
+23
View File
@@ -0,0 +1,23 @@
#include "utils.h"
unsigned long
u32to_u64(const unsigned int clr)
{
unsigned long mask = 0;
unsigned long alpha = DECODE_A(clr);
unsigned long red = DECODE_R(clr);
unsigned long green = DECODE_G(clr);
unsigned long blue = DECODE_B(clr);
return (alpha << 48) | (red << 32) | (green << 16) | (blue);
}
unsigned int
u64to_u32(const unsigned long clr, const unsigned long u64_div)
{
unsigned int a = ((clr >> 48) & LONG_BYTE);
unsigned int r = ((clr >> 32) & LONG_BYTE);
unsigned int g = ((clr >> 16) & LONG_BYTE);
unsigned int b = (clr & LONG_BYTE);
return ENCODE_ARGB((a / u64_div), (r / u64_div), (g / u64_div),
(b / u64_div));
}