getr8(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ getr8 β€” the "gimme just the red/green/blue bestie" collection ✨

ok so real talk, this is the Allegro manual page for a whole little squad of functions: getr8, getg8, getb8, getr15, getg15, getb15, getr16, getg16, getb16, getr24, getg24, getb24, getr32, getg32, getb32. that's fifteen (15) whole functions and yes they all do basically the same cute thing. the way that Allegro game programming library just handed us an entire color-component extraction toolkit. we love to see it πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

int getr8(int c);

int getg8(int c);

int getb8(int c);

int getr15(int c);

int getg15(int c);

int getb15(int c);

int getr16(int c);

int getg16(int c);

int getb16(int c);

int getr24(int c);

int getg24(int c);

int getb24(int c);

int getr32(int c);

int getg32(int c);

int getb32(int c);

πŸŽ€ DESCRIPTION πŸŽ€

ok so picture this: you've got a color, right? and it's in a display dependent format (iykyk, the format depends on your color depth and all that). these functions are the ones that go in and extract exactly one of the red, green, or blue components for you. and the values you get back? they range 0-255. every single time. periodt. πŸ’–

so like, getr8 gets the red from an 8-bit pixel, getg15 gets the green from a 15-bit pixel, getb32 gets the blue from a 32-bit pixel β€” you see the pattern bestie, it's literally the color letter plus the depth number. no cap.

here's the iconic example straight from the source, copy it exactly ok:

int r, g, b, color_value;

color_value = _getpixel15(screen, 100, 100);
r = getr15(color_value);
g = getg15(color_value);
b = getb15(color_value);

see how it's giving "grab the pixel, then pull each component out one by one"? that's the whole vibe. main character energy from a single int 🌈


πŸ’œ SEE ALSO πŸ’œ


ok that's the whole page bestie, go forth and extract some components, you're gonna slay πŸ¦‹βœ¨

this was Allegro, version 4.4.3, and this little page is filed under getr8(3) β€” mwah, bye! πŸ’–πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from