getpixel(3)
π getpixel(3) π
okay bestie, welcome to the Allegro manual β yes, the game programming library, we're being β¨productiveβ¨ today. this one's a lil function called getpixel and she is so simple it's almost suspicious. let's go π¦
πΈ NAME πΈ
getpixel β reads a pixel from a bitmap. that's it. that's the whole job. Allegro game programming library behavior, no cap π
β¨ SYNOPSIS β¨
#include <allegro.h>
int getpixel(BITMAP *bmp, int x, int y);
π DESCRIPTION π
so you give her a point (x, y) and she reads the pixel right there in the bitmap. that's the vibe. one point, one pixel, done. π
π RETURN VALUE π
she hands you back the value of that pixel β in the color format of the bitmap, so like, whatever format that bitmap speaks, that's what you get back. π«Ά
but if the point lies outside the bitmap (and heads up, she's ignoring the clipping rectangle here, so it's about the actual bitmap bounds), you get -1. periodt.
β οΈ WARNING, and this one's important bestie, don't skip it:-1is also a totally valid pixel value for pixels in 32-bit bitmaps with an alpha channel β specifically whenR,G,B,Aare all equal to255. so you literally cannot use "is it-1?" as a test for whether you're inside the bitmap when you're dealing with those. it will lie to you. it will betray you. π
the only reliable predicate in those cases is is_inside_bitmap(). use her. trust her. she's the main character here. π
and if you wanna pull the individual color components out of that pixel value, that's the getr() / getg() / getb() / geta() family of functions. they're the girlies for that job. π§
π SEE ALSO π
putpixel(3)_getpixel(3)is_inside_bitmap(3)getr(3)getg(3)getb(3)geta(3)ex12bit(3)exalpha(3)exflame(3)exlights(3)
and that's the whole page, bestie!! π this lil gem came to you courtesy of Allegro, version 4.4.3 β go read a pixel, or don't, either way you understood the assignment. mwah π β¨π
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms