al_get_video_frame(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_get_video_frame πŸ’–

okay bestie, welcome to the Allegro 5 API ✨ this one lives in the alleg5 manual and it's literally the moment your video finally shows you a picture πŸŽ¬πŸ¦‹


🌸 SYNOPSIS 🌸

#include <allegro5/allegro_video.h>

ALLEGRO_BITMAP *al_get_video_frame(ALLEGRO_VIDEO *video)

✨ DESCRIPTION ✨

so this one hands you the current video frame. that's it, that's the whole vibe πŸ’…

⚠️ IMPORTANT ⚠️ the bitmap is owned by the video, so do NOT try to free it. nope. don't. put the free() down. πŸ™ˆ

and like, it stays valid until the next call to al_get_video_frame β€” so if you're holding onto it, you better be done with it before you call this again, fr fr 😭


πŸŽ€ the pixel situation πŸŽ€

ngl this is the part that gets people: videos often do not use square pixels. so the recommended way to draw a video frame is code like this β€” this is the move, bestie, this is what slays πŸ‘‘

float scale = 1.0; /* Adjust this to fit your target bitmap dimensions. */
ALLEGRO_BITMAP* frame = al_get_video_frame(video);
float sw = al_get_bitmap_width(frame);
float sh = al_get_bitmap_height(frame);
float dw = scale * al_get_video_scaled_width(video);
float dh = scale * al_get_video_scaled_height(video);
al_draw_scaled_bitmap(frame, 0, 0, sw, sh, 0, 0, dw, dh, 0);

see how it pulls sw and sh from the frame but dw and dh from the scaled width and height? that's the whole trick, iykyk 🧚✨


πŸ¦‹ SINCE πŸ¦‹

5.1.0 β€” she's been iconic since day one, no cap πŸ’œ


πŸ’œ SEE ALSO πŸ’œ

those two are the ones doing the heavy lifting in that example above, so go say hi 🫢


and that's the page!! brought to you by the Allegro reference manual for al_get_video_frame(3alleg5) β€” go get that frame, bestie, you're the main character πŸŒˆπŸ‘‘πŸ’–

πŸ“¦ where this page comes from