stretch_blit(3)

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

πŸ’– stretch_blit β€” the glow-up your bitmaps deserve πŸ’–

okay so bestie, you know stretch_blit(3) from the Allegro manual? it's the Allegro game programming library's very own ✨scaler✨ and honestly? iconic. she takes a rectangular area from one bitmap and makes it fit into another one, any size you want. it's giving "glow-up montage" but for pixels. πŸ‘‘


🌸 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 basically she's blit()'s cooler older sister πŸ’… β€” same energy, except she can scale images, which means your source rectangle and your destination rectangle do not have to be the same size. glow-up complete. but there's a catch, and it's a real one, so listen up bestie:

  • both the source and the destination bitmaps have to be the same color depth. no mixing, no matching, periodt.
  • this routine does not do as much safety checking as the regular blit(). she's a little unhinged like that. πŸ™ˆ

and because she's not doing the safety checks, the responsibility is 100% on you:

⚠️ do not copy from areas outside the source bitmap. fr fr, just don't. ⚠️ you cannot blit between overlapping regions β€” meaning you have to use different bitmaps for the source and the destination. no self-overlap shenanigans. ⚠️ and the source must be a memory bitmap. that's the vibe check she needs you to pass.

here's the moment you've been waiting for, the example:

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

look at her go πŸ¦‹ whole bitmap, whole screen, zero drama (as long as you followed the rules above, bestie).


πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page, bestie β€” brought to you by Allegro, version 4.4.3, the same manual that's been feeding us since forever. stay stretched, stay slay. πŸ’œβœ¨

πŸ“¦ where this page comes from