getr(3alleg4)
π getr, getg, getb, geta β the Allegro color-splitting girlies π
okay bestie, so this is getr(3alleg4), straight out of the Allegro manual, and it's literally the four functions you need when you've got a packed color and you wanna know what's inside it. let's go β¨
β¨ NAME β¨
getr, getg, getb, geta β pull one single color component out of whatever pixel format you're currently rocking. part of the Allegro game programming library, obviously π
β¨ SYNOPSIS β¨
#include <allegro.h>
int getr(int c);
int getg(int c);
int getb(int c);
int geta(int c);
β¨ DESCRIPTION β¨
so here's the vibe: you hand these functions a color c that's already in the format your current video mode is using, and they hand you back one of the red, green, blue, or alpha components. the components range 0-255, bestie, so you get a nice full byte of range π
the way that works is that these are the smart ones β they peek at your current setup and call the preceding 8, 15, 16, 24, or 32-bit get functions as appropriate. so you don't gotta remember which depth you're in. iconic, honestly π
β οΈ heads up: the alpha part is only meaningful for 32-bit pixels. don't come crying to me when geta gives you nonsense at other depths, i warned you π
here's the example, verbatim, no notes:
int r, g, b, color_value;
color_value = getpixel(screen, 100, 100);
r = getr(color_value);
g = getg(color_value);
b = getb(color_value);
look at that. grab a pixel, crack it open, get your channels. main character energy fr fr πΈ
β¨ SEE ALSO β¨
okay that's the whole page, you're welcome π«Ά this was Allegro, version 4.4.3 β go forth and extract your color components, bestie, you're gonna slay πβ¨π¦
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms