stretch_blit(3alleg4)

πŸ’– stretch_blit β€” the glow-up your bitmaps have been waiting for πŸ’–

okay bestie, so this one's from the Allegro manual (the game programming library, you know the one) and it's literally the function that makes your tiny sprite fill the whole entire screen. no cap. ✨


🌸 SYNOPSIS 🌸

#include <allegro.h>

void stretch_blit(BITMAP *source, BITMAP *dest, int source_x, source_y,
source_width, source_height, int dest_x, dest_y, dest_width,
dest_height);

πŸ¦‹ DESCRIPTION πŸ¦‹

so. it's giving blit() energy, except β€” plot twist β€” it can scale images. which means the source rectangle and the destination rectangle do not have to be the same size. iconic behavior honestly.

but here's the catch, and I need you to actually hear me on this one:

  • the source and destination bitmaps must be the same color depth. non-negotiable. πŸ’…
  • this routine does NOT do as much safety checking as the regular blit(). it's the chill older sibling who doesn't check if you locked the door.
  • so you gotta be careful: do not copy from areas outside the source bitmap. fr fr, don't do it.
  • you also cannot blit between overlapping regions β€” meaning you must use different bitmaps for the source and the destination. yes, actually different ones.
  • oh and also? the source must be a memory bitmap. periodt. πŸ‘‘

example time, because I know you want one:

BITMAP *bmp;
...
/* Stretch bmp to fill the screen. */
stretch_blit(bmp, screen, 0, 0, bmp->w, bmp->h,
             0, 0, SCREEN_W, SCREEN_H);

see how it just... takes your little bmp and stretches it across the entire screen? main character energy, truly. 🌈


✨ SEE ALSO ✨

the whole friend group, go say hi:


🫢 quick vibe check before you go: same color depth, no out-of-bounds source reads, no overlapping regions, source = memory bitmap. do that and you're slaying. πŸ’–

and that's the whole page, bestie! this came straight out of the Allegro manual, version 4.4.3 β€” so go forth and stretch responsibly. mwah. πŸ’…βœ¨πŸŽ€