getpixel(3alleg4)

πŸ’– getpixel πŸ’–

okay bestie, so this is a page from the Allegro manual β€” the game programming library, version 4.4.3, and this specific little icon is all about reading a single pixel out of a bitmap. it's in section 3 (that's library calls, iykyk) and the manual name is getpixel(3alleg4). yes the "4" is doing a lot of work. she's serving legacy. πŸŽ€


✨ SYNOPSIS ✨

#include <allegro.h>

int getpixel(BITMAP *bmp, int x, int y);

🌸 DESCRIPTION 🌸

she reads one single pixel from the point (x, y) inside the bitmap. that's it. that's the whole job. one pixel. main character energy, honestly. πŸ’…


🫢 RETURN VALUE 🫢

  • returns -1 if the point lands outside the bitmap β€” and heads up, this check ignores the clipping rectangle, so the clip rect does not save you here. it's the raw bitmap bounds or nothing.
  • otherwise it returns the value of that pixel, expressed in the color format of the bitmap. every bitmap's got its own flavor and you get the number in that flavor. periodt. ✨
⚠️ okay this part is IMPORTANT, don't scroll past it. -1 is also a completely valid pixel value for 32-bit bitmaps with an alpha channel β€” specifically when R, G, B, and A are all equal to 255. so if you're testing against -1 to figure out whether you're inside the bitmap, that test will lie to you on those bitmaps. πŸ’€ in those cases, the only reliable predicate is is_inside_bitmap().

and if you wanna pull the individual color components out of that pixel value, that's what the getr() / getg() / getb() / geta() little family is for. they're a whole friend group. 🧚


πŸ‘€ SEE ALSO πŸ‘€


and that's the whole page, bestie. this one came from the Allegro manual, version 4.4.3, filed under getpixel(3alleg4). go read your pixels responsibly. mwah. πŸ’–πŸ¦‹πŸŒΈ